Re: ALTER TABLE ... TO ... to change related names

From: Dennis Björklund <db(at)zigo(dot)dhs(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, <pgsql-hackers(at)postgresql(dot)org>, Jonathan Gardner <jgardner(at)jonathangardner(dot)net>
Subject: Re: ALTER TABLE ... TO ... to change related names
Date: 2003-08-30 22:55:15
Message-ID: Pine.LNX.4.44.0308310019450.4053-100000@zigo.dhs.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, 30 Aug 2003, Tom Lane wrote:

> > I don't understand why the serial columns sequence should be visible as
> > other sequences.
>
> Backwards compatibility, if nothing else. Are you prepared to break
> every existing dump file that has
> CREATE TABLE ser (f1 serial);
> SELECT pg_catalog.setval('ser_f1_seq', 1, false);

I think breaking backward compability not always bad. If

a) it the change is sound and good for the long term
b) there is a solution that can be included for a number
of revisions and where you preferably can turn on/off
the feature with a variable.

The question is if the change is important enough to warrent such a
breakage. Logically I think it's preferable.

> > create table foo (x serial);
> > select nextval('foo.x');
>
> This conflicts with the existing provisions for accessing sequences
> using ordinary schema-qualified names ('schema.sequence').

That can of course be fixed by using some other selector then . (dot)
like nextval('foo#x') or one can keep the dot and resolve it any way. But
I'm not trying to come up with the best syntax here. I was more interested
in the namespace change, to keep serial sequence names out of the "global"
namespace.

The exact syntax is the last problem. The backward compability is a much
bigger issue (with 7.3 since older dumps has no problem).

> The work I would actually like to see getting done in this area is
> the existing TODO item about using Oracle-compatible syntax for nextval
> et al, namely that you can write
> sequence.nextval
> or
> schema.sequence.nextval
> rather than nextval('sequence') or nextval('schema.sequence').

It's a separate issue that I also would welcome.

--
/Dennis

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Rod Taylor 2003-08-30 23:12:01 Re: ALTER TABLE ... TO ... to change related names
Previous Message Tom Lane 2003-08-30 22:35:48 Re: Is it a memory leak in PostgreSQL 7.4beta?