From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com> |
Cc: | feikesteenbergen(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org |
Subject: | Re: BUG #15198: nextval() accepts tables/indexes when adding a default to a column |
Date: | 2018-05-16 14:14:36 |
Message-ID: | CAKFQuwY2NUO92XrF7Sdg7-2kFJ3AjgcuF+VUkTSpVOa60kBdag@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
On Wed, May 16, 2018 at 7:00 AM, Peter Eisentraut <
peter(dot)eisentraut(at)2ndquadrant(dot)com> wrote:
> > bugtest=# INSERT INTO demo (i, j) VALUES (1,1);
> > INSERT 0 1
> > bugtest=# INSERT INTO demo (i, j) VALUES (DEFAULT, DEFAULT);
> > ERROR: 42809: "demo" is not a sequence
> > LOCATION: init_sequence, sequence.c:1139
>
> You are right that this is not optimal behavior. I'm not sure if it's
> worth fixing, however. (Introduce a regsequence type to use in place of
> regclass?)
There is a big note on the functions-sequence page in the docs covering
late binding and text. A addition like below is an acceptable solution for
me:
Additionally, since pg_class contains objects other than sequences it is
possible to specify a default that, at runtime, points to a non-sequence
object and provokes an error. (i.e., the type of the pointed to pg_class
record is not checked during the cast but during function evaluation).
David J.
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2018-05-16 14:14:39 | Re: BUG #15198: nextval() accepts tables/indexes when adding a default to a column |
Previous Message | Peter Eisentraut | 2018-05-16 14:14:25 | issue with updatable cursors |