[PG19] CREATE SCHEMA puts an index or trigger on a same-named temp table

From: shihao zhong <zhong950419(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Noah Misch <noah(at)leadboat(dot)com>, Kirill Reshke <reshkekirill(at)gmail(dot)com>, jian he <jian(dot)universality(at)gmail(dot)com>
Subject: [PG19] CREATE SCHEMA puts an index or trigger on a same-named temp table
Date: 2026-10-17 05:13:37
Message-ID: CAGRkXqRMkfs25+7ReRkF4WCogEnD1k1=L=fmA_kxbtDfmhFn-g@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi hackers,

This is Low item 2 from my list of 19 bugs in [1].

In v18 an unqualified CREATE SCHEMA element got the new schema's name
filled in. a9c350d9e stopped doing that, and the revert in 962e0a723
(e0fdc3f54b4 in 19) kept it.

So the name now goes through search_path, where pg_temp comes first:

create temp table t (a int);
create schema s
create table t (a int)
create index i on t (a);

On 19 and master the index lands on the temp table, with no error. A
trigger does the same, a foreign key in s.t fails, and a view on t
quietly becomes a temp view. v18 puts them in s, or raises an error
for the view.

0001 address it by fills in the name again as v18 did, on a copy of
the elements.

Thanks,
Shihao

Attachment Content-Type Size
v1-0001-Qualify-unqualified-names-in-CREATE-SCHEMA-elemen.patch application/octet-stream 2.4 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Ayush Tiwari 2026-10-17 05:45:54 Re: Bug in logical decoding with DDL and subtransactions
Previous Message shihao zhong 2026-10-17 04:31:18 Re: First draft of PG 19 release notes