Thread: Re: [BUGS] BUG #2907: pg_get_serial_sequence quoting

Re: [BUGS] BUG #2907: pg_get_serial_sequence quoting

From
Bruce Momjian
Date:
Adriaan van Os wrote:
> Bruce Momjian wrote:
> 
> > Strangely, this was reported before, but not until November of 2006:
> > 
> >     http://archives.postgresql.org/pgsql-general/2006-11/msg01111.php
> 
> That was a follow up on this thread 
> <http://archives.postgresql.org/pgsql-hackers/2004-10/msg00964.php>.

Interesting.  In this thread the reason for the current behavior is
given as:

> I presume the reason for that is that the first paramater can be
> qualified:
> 
> select pg_get_serial_sequence('"public"."FOO"', 'Ff1');

Would someone explain why qualification makes us lowercase the first
parameter by default?  I don't understand it well enough to document it.
I notice this does not work:
test=> SELECT pg_get_serial_sequence('"Test"', '"Xx"');

So do we just say because quotes might be needed to distinguish the
schame from the table name, we don't auto-quote the first parameter?

--  Bruce Momjian   bruce@momjian.us EnterpriseDB    http://www.enterprisedb.com
 + If your life is a hard drive, Christ can be your backup. +


Re: [BUGS] BUG #2907: pg_get_serial_sequence quoting

From
Tom Lane
Date:
Bruce Momjian <bruce@momjian.us> writes:
>> I presume the reason for that is that the first paramater can be
>> qualified:
>> select pg_get_serial_sequence('"public"."FOO"', 'Ff1');

> Would someone explain why qualification makes us lowercase the first
> parameter by default?  I don't understand it well enough to document it.

The point is that we have to parse the first parameter, whereas the
second one can be taken literally.
        regards, tom lane


Re: [BUGS] BUG #2907: pg_get_serial_sequence quoting

From
Adriaan van Os
Date:
Tom Lane wrote:
> Bruce Momjian <bruce@momjian.us> writes:
>>> I presume the reason for that is that the first paramater can be
>>> qualified:
>>> select pg_get_serial_sequence('"public"."FOO"', 'Ff1');
> 
>> Would someone explain why qualification makes us lowercase the first
>> parameter by default?  I don't understand it well enough to document it.
> 
> The point is that we have to parse the first parameter, whereas the
> second one can be taken literally.

It still looks inconsistent and ugly. I think the design mistake of pg_get_serial_sequence is that 
it takes two parameters rather than one (a fully qualified doublequoted columnname path) or three 
(optionally empty schema, tablename, columnname, all three literal).

Regards,

Adriaan van Os