Re: [HACKERS] Open 6.4 items
От | Brook Milligan |
---|---|
Тема | Re: [HACKERS] Open 6.4 items |
Дата | |
Msg-id | 199808241604.KAA08726@trillium.nmsu.edu обсуждение исходный текст |
Ответ на | Re: [HACKERS] Open 6.4 items ("Thomas G. Lockhart" <lockhart@alumni.caltech.edu>) |
Список | pgsql-hackers |
> SERIAL type auto-creates sequence I won't have time to do this for v6.4. It's not quite the same as the PRIMARY KEY parser solution, since the sequence must be created _before_ the main portion of the CREATE TABLE command is executed, rather than after. We should go through the high-level parser routines and allow all of them to return multiple parse trees; at the moment I've got a special-case workaround implemented for the PRIMARY KEY code which doesn't generalize very well. Actually, sequences can be defined _either_ before or after the table. See below. Cheers, Brook =========================================================================== -- create id sequence before table drop sequence id_sequence_before; create sequence id_sequence_before start 1; -- create table drop table id_table; create table id_table ( id_before int4 default nextval ('id_sequence_before'), id_after int4 default nextval ('id_sequence_after'), name text ); -- create id sequence after table drop sequence id_sequence_after; create sequence id_sequence_after start 1; -- populate table insert into id_table (name) values ('one'); insert into id_table (name) values ('two'); insert into id_table (name) values ('three'); select * from id_table; =========================================================================== id_before|id_after|name ---------+--------+----- 1| 1|one 2| 2|two 3| 3|three (3 rows) ===========================================================================
В списке pgsql-hackers по дате отправления: