Re: [PATCHES] ALTER SEQUENCE

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Rod Taylor <rbt(at)rbt(dot)ca>
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-07 16:27:13
Message-ID: 200303071627.h27GRDn16136@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers pgsql-patches


Does it make sense to avoid sequence name collisions if applications
have to refer to sequence names directly? I mean, I can imagine a case
where a restore would return a sequence name that is different from the
one that dumped it. pg_dump may be hacked to fix that (look up the
sequence for the column) but what about applications. Seems any real
solution is going to need removal of direct sequence name references in
applications.

---------------------------------------------------------------------------

Rod Taylor wrote:
-- Start of PGP signed section.
> On Mon, 2003-03-03 at 20:47, Christopher Kings-Lynne wrote:
> > Hey, with this new ALTER SEQUENCE patch, how about this for an idea:
> >
> > I submitted a patch to always generate non-colliding index and sequence
> > names. Seemed like an excellent idea. However, 7.3 dumps tables like this:
> >
> > CREATE TABLE blah
> > a SERIAL
> > );
> >
> > SELECT SETVAL('blah_a_seq', 10);
> >
> > Sort of thing...
> >
> > How about we add a new form to ALTER SEQUENCE <sequence> ...?
> >
> > ALTER SEQUENCE ON blah(a) CURRVAL 10.... (or whatever the syntax is)
>
> The spec proposes:
>
> ALTER SEQUENCE <sequence> RESTART WITH <value>;
>
>
> I suppose (since SERIAL is nonstandard anyway) we could do:
>
> ALTER SEQUENCE ON table(column) RESTART WITH <value>;
>
> The problem is that we really don't have an easy way of determining if
> there is a sequence on table(column) to start with and ONLY that table.
>
> I don't think I'd want to allow that on user sequences at all because
> they're often used in stranger ways, and the user doing the alteration
> may not know that.
>
>
> As far as getting dependencies on the sequence, the currently proposed
> method of retrieving the next value of a sequence generator is 'NEXT
> VALUE FOR <sequence>' -- but Tom isn't going to like that :)
>
>
> Might get somewhere by making a special domain thats marked as being
> serial, and using that in the column. Create the sequence and tie it to
> the domain. Now you know the sequence tied to the column (because it's
> on the domain). Just disallow 'special' serial sequences & domains to
> be used in other ways.
>
> Prevention of the domain from being altered would also help, as you can
> then prevent the default from changing.
>
> --
> Rod Taylor <rbt(at)rbt(dot)ca>
>
> PGP Key: http://www.rbt.ca/rbtpub.asc
-- End of PGP section, PGP failed!

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jean-Christian Imbeault 2003-03-07 16:33:10 Unexpected parse behaviour for date to timestamp conversion
Previous Message valerian 2003-03-07 16:04:23 Re: index on lower(column) is very slow

Browse pgsql-hackers by date

  From Date Subject
Next Message Rod Taylor 2003-03-07 16:35:23 Re: [PATCHES] ALTER SEQUENCE
Previous Message Tom Lane 2003-03-07 15:38:19 Re: Updateable views...

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2003-03-07 16:34:15 Re: new format for describe (repost #2)
Previous Message Kevin Brown 2003-03-07 07:07:52 Re: stats_command_string default?