2 or more columns of type 'serial' in a table

Started by Aggarwal , Ajayabout 25 years ago2 messagesgeneral
Jump to latest
#1Aggarwal , Ajay
ajay@crossbeamsys.com

Kindly Cc your responses to ajay@crossbeamsys.com as well..
I am having a problem, while trying to CREATE a table with more than one
column of type 'serial'. Apparently only one sequence gets created and that
is for the last 'serial' type column in the table. The CREATE command seems
to succeed though ....
The table I am trying to create looks like this:
CREATE TABLE my_table (
charId serial,
charName varchar (32) PRIMARY KEY,
index serial,
index2 serial,
value int
);
I am working with postgres version 7.0.3-2
Ajay

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Aggarwal , Ajay (#1)
Re: 2 or more columns of type 'serial' in a table

"Aggarwal , Ajay" <ajay@crossbeamsys.com> writes:

I am having a problem, while trying to CREATE a table with more than one
column of type 'serial'. Apparently only one sequence gets created and that
is for the last 'serial' type column in the table.

How embarrassing ... I wonder how long that's been broken?

The fix in 7.0.3 is to change line 716 of src/backend/parser/analyze.c
from
blist = lcons(sequence, NIL);
to
blist = lappend(blist, sequence);

Fixed for 7.1. Thanx for the report.

regards, tom lane