From: | Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com> |
---|---|
To: | 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:00:02 |
Message-ID: | f0ca3887-aa58-4f55-fcc4-3d49a986e15c@2ndquadrant.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
On 5/16/18 05:29, PG Bug reporting form wrote:
> bugtest=# CREATE TABLE demo(i int default nextval('demo') PRIMARY KEY);
> CREATE TABLE
> bugtest=# ALTER TABLE demo ADD COLUMN j int default nextval('demo_pkey');
> ALTER TABLE
> bugtest=# \d demo
> Table "public.demo"
> Column | Type | Collation | Nullable | Default
> --------+---------+-----------+----------+--------------------------------
> i | integer | | not null | nextval('demo'::regclass)
> j | integer | | | nextval('demo_pkey'::regclass)
> Indexes:
> "demo_pkey" PRIMARY KEY, btree (i)
>
> 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?)
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Eisentraut | 2018-05-16 14:14:25 | issue with updatable cursors |
Previous Message | PG Bug reporting form | 2018-05-16 13:36:43 | BUG #15200: Support ANSI OFFSET .. FETCH syntax with bind variables |