Re: [PATCHES] ALTER SEQUENCE

From: Rod Taylor <rbt(at)rbt(dot)ca>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>, Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCHES] ALTER SEQUENCE
Date: 2003-03-05 04:22:07
Message-ID: 1046837902.17609.63.camel@jester
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers pgsql-patches

On Tue, 2003-03-04 at 19:14, Tom Lane wrote:
> Rod Taylor <rbt(at)rbt(dot)ca> writes:
> > Might get somewhere by making a special domain thats marked as being
> > serial, and using that in the column.
>
> I recall some discussion last year about making serial et al. into
> domains over int4 and int8, rather than their current utter-hack
> implementation. Can't recall if we found a problem with the idea,
> or no one got around to doing it, or it just didn't seem to clean
> things up enough to be worth the trouble. (AFAICS you'd still need
> special-case code to set up the appropriate default expression for
> each column; the domain constraint mechanism wouldn't handle that
> for you.)

Slightly different thought. I had actually submitted a patch for the
above, but would have to dig through the archives to determine what the
problem was.

CREATE TABLE tab (column SERIAL);

Generates:

table(column serial_table_column)

domain serial_table_column
as int4 default nextval("serial_table_column")

Sequence serial_table_column.

Now, rather than having knowedge of the contents of nextval, we simply
trace the dependencies of the column through the domain to the sequence
-- since these will be known to exist.

Thus the below command could function fairly easily on serials:

ALTER SEQUENCE ON table(column)

The alternative is to simply implement the proposed 200N sequence
generator spec, which includes 'NEXT VALUE FOR <sequence>'.

With that in place, our default would then depend on the sequence, and
the ALTER SEQUENCE ON table(column) would function.
--
Rod Taylor <rbt(at)rbt(dot)ca>

PGP Key: http://www.rbt.ca/rbtpub.asc

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jeff Davis 2003-03-05 05:18:36 Re: Why PostgreSQL?
Previous Message Tom Lane 2003-03-05 04:07:32 Re: Help with select into

Browse pgsql-hackers by date

  From Date Subject
Next Message Marc G. Fournier 2003-03-05 06:00:47 test to be ignored ...
Previous Message Tom Lane 2003-03-05 04:04:03 Re: Error codes revisited

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2003-03-05 15:36:06 Re: [PATCHES] Non-colliding auto generated names
Previous Message Tom Lane 2003-03-05 00:14:23 Re: [PATCHES] ALTER SEQUENCE