NEXTVAL function Bug

Started by Dan Wilsonover 25 years ago2 messagesgeneral
Jump to latest
#1Dan Wilson
phpPgAdmin@acucore.com

Ok... I think I found a bug... tell me if I'm smoking something on this:

I create a table with a mixed case name... everything works fine until I try
to use the sequence created with the SERIAL datatype.

test_db=# create table "mixed_Case" ("mix_id" SERIAL, "mix_var"
varchar(50));
NOTICE:  CREATE TABLE will create implicit sequence 'mixed_Case_mix_id_seq'
for SERIAL column 'mixed_Case.mix_id'
NOTICE:  CREATE TABLE/UNIQUE will create implicit index
'mixed_Case_mix_id_key' for table 'mixed_Case'
CREATE
test_db=# \d "mixed_Case"
                                Table "mixed_Case"
 Attribute |    Type     |                        Modifier
-----------+-------------+--------------------------------------------------
-------
 mix_id    | integer     | not null default
nextval('mixed_Case_mix_id_seq'::text)
 mix_var   | varchar(50) |
Index: mixed_Case_mix_id_key

test_db=# insert into "mixed_Case" (mix_id, mix_var) values
(nextval('mixed_Case_mix_id_seq'), 'not working');
ERROR: Relation 'mixed_case_mix_id_seq' does not exist
test_db=# insert into "mixed_Case" (mix_id, mix_var) values
(nextval('mixed_Case_mix_id_seq'::text), 'not working');
ERROR: Relation 'mixed_case_mix_id_seq' does not exist
test_db=# insert into "mixed_Case" (mix_id, mix_var) values
(nextval("mixed_Case_mix_id_seq"::text), 'not working');
ERROR: Attribute 'mixed_Case_mix_id_seq' not found
test_db=# insert into "mixed_Case" (mix_id, mix_var) values
(nextval("mixed_Case_mix_id_seq"), 'not working');
ERROR: Attribute 'mixed_Case_mix_id_seq' not found
test_db=#

I know I could just do a: insert into "mixed_Case" (mix_var) values ('not
working')

But this is for phpPgAdmin and so due to certain issues, I need to have the
nextval function work as it would without a mixed case table name.

Is this expected behavior?

-Dan

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Dan Wilson (#1)
Re: NEXTVAL function Bug

"Dan Wilson" <phpPgAdmin@acucore.com> writes:

test_db=# insert into "mixed_Case" (mix_id, mix_var) values
(nextval('mixed_Case_mix_id_seq'), 'not working');
ERROR: Relation 'mixed_case_mix_id_seq' does not exist

You need to do it like this:
nextval('"mixed_Case_mix_id_seq"')

IMHO it's only a historical artifact that nextval wants a quoted name
at all. The syntax should have been something like nextval(seqname) or
seqname.nextval, with no string literal.

regards, tom lane