CONVERT function is seriously broken

Started by Tom Laneabout 23 years ago6 messages
#1Tom Lane
tgl@sss.pgh.pa.us

I have just noticed that the implementation of
CONVERT(text USING encoding_name)
tries to do database access during the grammar phase, viz it looks
up the encoding_name in pg_conversion and replaces it with an OID.

This is not workable; consider the situation where we are in an
already-aborted transaction. Using a pg_conversion OID in stored rules
isn't very acceptable either.

Unfortunately, I don't see any way offhand to fix this without an
initdb :-(.

regards, tom lane

#2Bruce Momjian
pgman@candle.pha.pa.us
In reply to: Tom Lane (#1)
Re: CONVERT function is seriously broken

Tom Lane wrote:

I have just noticed that the implementation of
CONVERT(text USING encoding_name)
tries to do database access during the grammar phase, viz it looks
up the encoding_name in pg_conversion and replaces it with an OID.

This is not workable; consider the situation where we are in an
already-aborted transaction. Using a pg_conversion OID in stored rules
isn't very acceptable either.

Unfortunately, I don't see any way offhand to fix this without an
initdb :-(.

Ooch, that hurts. How bad would it be if it was broken in 7.3?

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#2)
Re: CONVERT function is seriously broken

Bruce Momjian <pgman@candle.pha.pa.us> writes:

Tom Lane wrote:

Unfortunately, I don't see any way offhand to fix this without an
initdb :-(.

Ooch, that hurts. How bad would it be if it was broken in 7.3?

We could dike out the feature:

convert_list:
a_expr USING any_name
{
elog(ERROR, "CONVERT(... USING ...) is not implemented");
}

Short of that, I think we need an initdb to change the function
signature for the convert() function. It needs to take a (suitably
quoted) text parameter, not an OID.

Since we forced initdb only a week ago with beta3, I don't think there
is really a strong argument against doing it again. But probably Marc
will say that we need a beta4 at this point, instead of going for RC1...

regards, tom lane

#4Bruce Momjian
pgman@candle.pha.pa.us
In reply to: Tom Lane (#3)
Re: CONVERT function is seriously broken

Tom Lane wrote:

We could dike out the feature:

convert_list:
a_expr USING any_name
{
elog(ERROR, "CONVERT(... USING ...) is not implemented");
}

Short of that, I think we need an initdb to change the function
signature for the convert() function. It needs to take a (suitably
quoted) text parameter, not an OID.

Since we forced initdb only a week ago with beta3, I don't think there
is really a strong argument against doing it again. But probably Marc
will say that we need a beta4 at this point, instead of going for RC1...

He certainly will. We can shoot out beta4 and make it sort.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#5Marc G. Fournier
scrappy@hub.org
In reply to: Tom Lane (#3)
Re: CONVERT function is seriously broken

On Sat, 2 Nov 2002, Tom Lane wrote:

Bruce Momjian <pgman@candle.pha.pa.us> writes:

Tom Lane wrote:

Unfortunately, I don't see any way offhand to fix this without an
initdb :-(.

Ooch, that hurts. How bad would it be if it was broken in 7.3?

We could dike out the feature:

convert_list:
a_expr USING any_name
{
elog(ERROR, "CONVERT(... USING ...) is not implemented");
}

Short of that, I think we need an initdb to change the function
signature for the convert() function. It needs to take a (suitably
quoted) text parameter, not an OID.

Since we forced initdb only a week ago with beta3, I don't think there
is really a strong argument against doing it again. But probably Marc
will say that we need a beta4 at this point, instead of going for RC1...

Most definitely ... but beta3 was nice and short, and no reason why beta4
can't be as well ...

#6Tatsuo Ishii
t-ishii@sra.co.jp
In reply to: Tom Lane (#1)
Re: CONVERT function is seriously broken

I have just noticed that the implementation of
CONVERT(text USING encoding_name)
tries to do database access during the grammar phase, viz it looks
up the encoding_name in pg_conversion and replaces it with an OID.

This is not workable; consider the situation where we are in an
already-aborted transaction. Using a pg_conversion OID in stored rules
isn't very acceptable either.

Unfortunately, I don't see any way offhand to fix this without an
initdb :-(.

Sorry for the trouble and thanks for the fix.
--
Tatsuo Ishii