Re: BUG #15198: nextval() accepts tables/indexes when adding a default to a column

Andres Freund <andres@anarazel.de>

From: Andres Freund <andres@anarazel.de>
To: Feike Steenbergen <feikesteenbergen@gmail.com>
Cc: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>, Tom Lane <tgl@sss.pgh.pa.us>, pgsql-bugs@lists.postgresql.org
Date: 2018-05-17T16:21:19Z
Lists: pgsql-bugs
Hi,

On 2018-05-17 08:41:53 +0200, Feike Steenbergen wrote:
> On 16 May 2018 at 16:20, Peter Eisentraut
> <peter.eisentraut@2ndquadrant.com> wrote:
> 
> > In this case, they are putting the erroneous call into a column default,
> > so the difference ends up being getting the error at setup time versus
> > at run time, which is a difference of significance.
> 
> Yes, I'm not particularly concerned with nextval taking a regclass as
> an argument, and
> therefore raising this error, but I'd rather have this error at DDL
> time than at DML time.
> 
> I don't know how hard it would be to implement, but say, calling
> currval(regclass) when
> a default is defined should already throw this error at DDL time.
> 
> Or, when registering the default in the catalog, we verify that it is
> actually a sequence:

These alternatives seem like they're not an improvement.  I don't think
it's worth doing anything here.

Greetings,

Andres Freund