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

Started by shihao zhongabout 1 month ago3 messageshackers
Jump to latest
#1shihao zhong
zhong950419@gmail.com

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

Attachments:

t254248_1
v1-0001-Qualify-unqualified-names-in-CREATE-SCHEMA-elemen.patchapplication/octet-stream; name=v1-0001-Qualify-unqualified-names-in-CREATE-SCHEMA-elemen.patchDownload+8-6
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: shihao zhong (#1)
Re: [PG19] CREATE SCHEMA puts an index or trigger on a same-named temp table

shihao zhong <zhong950419@gmail.com> writes:

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:

Ooops, good catch. The patch needed some more work on comments,
and I also chose to go back to the old function naming
"setSchemaName..." instead of "checkSchemaName...", but the functional
correction is fine. Pushed.

regards, tom lane

#3shihao zhong
zhong950419@gmail.com
In reply to: Tom Lane (#2)
Re: [PG19] CREATE SCHEMA puts an index or trigger on a same-named temp table

Hi Tom,

Thanks for fixing it and for the cleanup.

Thanks,
Shihao