Skip site navigation (1) Skip section navigation (2)

Re: Proposed patch for sequence-renaming problems

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: Proposed patch for sequence-renaming problems
Date: 2005-09-28 15:09:45
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackerspgsql-patches
Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> What I am primarily worried about in your patch is the exposure of
> ::regclass as a recommended way of doing things.  I know we can
> discourage its us later, but once people start using something, it is
> hard to change.

Why shouldn't it be a recommended way of doing things?  It is certainly
far better than the existing text-argument way.

> Right now, we have three cases, SERIAL, DEFAULT with no-schema seqname,
> and DEFAULT with schema-specified seqname.  If we just do regclass
> internally for SERIAL, we don't have any user-visible change, except for
> the psql \d display of the default.  

> The second case already works because there is no class name.

No, it really wouldn't "work" at all.  It's unsafe if the user changes
the search path for example, and it certainly doesn't handle any of the
renaming or change-of-schema cases.

> It is
> only the last one where recommending regclass helps, but is it worth
> improving sequence/schema renaming by exposing and recommending a
> ::regclass syntax that will go away as soon as we fix this properly?

Please explain what you think a "proper" fix is.  I think this patch is
a proper fix.  I see no better alternative that we might implement

The only other thing that's been discussed is the SQL2003 syntax
	NEXT VALUE FOR sequencename
but this is in fact just syntactic sugar for something functionally
equivalent to nextval('sequencename'::regclass).  It cannot completely
replace all uses of the nextval function, because only a constant table
name can appear.

Hmm ... given the proposed patch, it would indeed take only a few more
lines in gram.y to support the NEXT VALUE FOR syntax ...

			regards, tom lane

In response to


pgsql-hackers by date

Next:From: William ZHANGDate: 2005-09-28 15:14:08
Subject: Re: Database file compatability
Previous:From: Tom LaneDate: 2005-09-28 14:22:51
Subject: Re: Database file compatability

pgsql-patches by date

Next:From: Bruce MomjianDate: 2005-09-28 15:25:07
Subject: Re: [PATCHES] Proposed patch for sequence-renaming problems
Previous:From: Pavel StehuleDate: 2005-09-28 14:30:54
Subject: SQL/XML publishing function experimental patch II

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group