Re: [HACKERS] Open 6.4 items

From: Brook Milligan <brook(at)trillium(dot)NMSU(dot)Edu>
To: lockhart(at)alumni(dot)caltech(dot)edu
Cc: maillist(at)candle(dot)pha(dot)pa(dot)us, hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] Open 6.4 items
Date: 1998-08-24 16:04:36
Message-ID: 199808241604.KAA08726@trillium.nmsu.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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)
===========================================================================

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jouni Ahto 1998-08-24 16:47:21 Re: [INTERFACES] Convert PGconn, PGresult to opaque types?
Previous Message Bruce Momjian 1998-08-24 15:42:55 Re: [HACKERS] minor problem with detecting int64 in configure