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
pgsql-hackers by date
| Next: | From: Marc G. Fournier | Date: 2003-03-05 06:00:47 |
| Subject: test to be ignored ... |
| Previous: | From: Tom Lane | Date: 2003-03-05 04:04:03 |
| Subject: Re: Error codes revisited |
pgsql-patches by date
| Next: | From: Bruce Momjian | Date: 2003-03-05 15:36:06 |
| Subject: Re: [PATCHES] Non-colliding auto generated names |
| Previous: | From: Tom Lane | Date: 2003-03-05 00:14:23 |
| Subject: Re: [PATCHES] ALTER SEQUENCE |
pgsql-general by date
| Next: | From: Jeff Davis | Date: 2003-03-05 05:18:36 |
| Subject: Re: Why PostgreSQL? |
| Previous: | From: Tom Lane | Date: 2003-03-05 04:07:32 |
| Subject: Re: Help with select into |