From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: reshkekirill@gmail.com
Subject: BUG #19023: Table DDL default column expression depending on temp objects
Date: Mon, 18 Aug 2025 13:32:24 +0000
Message-ID: <19023-0a5a85a44ec3f0c6@postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 19023
Logged by: Kirill Reshke
Email address: reshkekirill@gmail.com
PostgreSQL version: 18beta3
Operating system: any
Description:
I have found two cases when user can define a relation, which has temp
objects in its DEFAULT expression.
First example is:
```
reshke=# create temp sequence s1;
CREATE SEQUENCE
reshke=# create table tt(i int default nextval('s1'));
CREATE TABLE
```
I think it is a bug that PostgreSQL allows this DDL to successfully
complete. There is a validation for this type of DDL already, example:
```
reshke=# create table ttx(i int default nextval('s3'));
ERROR: relation "s3" does not exist
LINE 1: create table ttx(i int default nextval('s3'));
^
```
Since PostgreSQL already checks for its nextval() input, we can teach server
to also validate relation relpersistence, arent we?
Second example is with tables:
```
reshke=# create temp table x();
CREATE TABLE
reshke=# create table y (i int default nextval('x'));
CREATE TABLE
reshke=# insert into y default values ;
ERROR: cannot open relation "x"
DETAIL: This operation is not supported for tables.
```
WDYT? Is this indeed a bug?
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, reshkekirill@gmail.com
Subject: Re: BUG #19023: Table DDL default column expression depending on temp objects
In-Reply-To: <19023-0a5a85a44ec3f0c6@postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox