Re: [PATCHES] Non-colliding auto generated names

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>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCHES] Non-colliding auto generated names
Date: 2003-03-05 19:37:36
Message-ID: 200303051937.h25Jbai25617@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches


Interesting idea. The bigger problem is that apps who use the sequence
name also would have problems running after the restore. Seems we need
column.nextval() so you can increment the sequence without knowing the
sequence name, just the column name. Of course, this related to this
TODO item:

* Have sequence dependency track use of DEFAULT sequences,
seqname.nextval

Comments?

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

Rod Taylor wrote:
-- Start of PGP signed section.
> On Wed, 2003-03-05 at 10:36, Bruce Momjian wrote:
> > Ewe. There would no longer be a guaranteed name for the serial column
> > sequence. Of course, pg_depend has the information, but how do you get
> > at that when you create the dump file, and be _sure_ you are going to
> > hit the right name, especially if you restore only part of the dump.
> >
> > Seems this kills the idea of this patch. With 64-byte names, let's see
> > if we still get complaints about name conflicts.
>
> We are :)
>
> CREATE TABLE tab (col SERIAL);
>
> ALTER TABLE tab RENAME TO tab2;
>
> CREATE TABLE tab (col SERIAL);
>
>
> There is a chance we could do something like:
>
> ALTER SEQUENCE ON table(col) RESTART WITH <value>
>
> instead of
>
> SELECT setval("<sequence>", <value>);
>
>
> The ALTER SEQUENCE syntax isn't any worse than setval... I'd be willing
> to implement the feature in order to get this patch accepted.
>
> Oh, and welcome back!
>
> > ---------------------------------------------------------------------------
> >
> > Christopher Kings-Lynne wrote:
> > > OK,
> > >
> > > I have discovered a problem with my auto-naming patch. It's do to with
> > > dumping serial columns with pg_dump, eg:
> > >
> > > --
> > > -- TOC entry 2 (OID 1004551)
> > > -- Name: users_users; Type: TABLE; Schema: public; Owner: chriskl
> > > --
> > >
> > > CREATE TABLE users_users (
> > > userid serial NOT NULL,
> > > firstname character varying(255) NOT NULL,
> > > lastname character varying(255) NOT NULL,
> > > email character varying(255) NOT NULL
> > > );
> > >
> > > -- DATA DUMPED HERE
> > >
> > > --
> > > -- TOC entry 4 (OID 1004305)
> > > -- Name: users_users_userid_seq; Type: SEQUENCE SET; Schema: public; Owner:
> > > chriskl
> > > --
> > >
> > > SELECT pg_catalog.setval ('users_users_userid_seq', 126, true);
> > >
> > >
> > > How do we fix this problem?? Perhaps instead of a hard-coded sequence
> > > string, we can sub-SELECT for it...?
> > >
> > > Chris
> > >
> > >
> > >
> --
> 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-hackers by date

  From Date Subject
Next Message Rod Taylor 2003-03-05 19:47:04 Re: [PATCHES] Non-colliding auto generated names
Previous Message Josh Berkus 2003-03-05 17:25:30 Re: Best setup for RAM drive

Browse pgsql-patches by date

  From Date Subject
Next Message Rod Taylor 2003-03-05 19:47:04 Re: [PATCHES] Non-colliding auto generated names
Previous Message Peter Eisentraut 2003-03-05 17:12:17 Re: new format for describe (repost #2)