1
0
mirror of https://github.com/postgres/postgres.git synced 2026-10-23 13:29:09 +03:00

psql: Schema-qualify catalogs in ALTER DATABASE RESET completion

The tab-completion query used for ALTER DATABASE ... RESET referenced
pg_db_role_setting and pg_database without schema qualification, so a
same-named relation earlier in search_path could be used instead of the
system catalogs.  This could make psql offer misleading RESET candidates.

Commit dbf5a83d46 schema-qualified the unnest() call in this same query,
but the catalog references were still left unqualified.  Fix that by
referring to pg_catalog.pg_db_role_setting and pg_catalog.pg_database
explicitly.

Backpatch to 18, where the tab-completion for ALTER DATABASE ... RESET
was introduced.

Bug: #19523
Reported-by: Zhou Digoal <digoal@126.com>
Author: Vismay Tiwari <vismay.t@gmail.com>
Reviewed-by: Paul Kim <mok03127@gmail.com>
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Discussion: https://postgr.es/m/19523-424457118202f570@postgresql.org
Discussion: https://postgr.es/m/CALHMmB84qkCgv3QAR78YawgfqQZCxSPkRhppxzU=e6fg8RA+AA@mail.gmail.com
Backpatch-through: 18
This commit is contained in:
Fujii Masao
2026-09-11 18:14:14 +09:00
parent 2bc7b71dc1
commit 043bc68b22

View File

@@ -1032,8 +1032,8 @@ static const SchemaQuery Query_for_trigger_of_table = {
#define Query_for_list_of_database_vars \
"SELECT conf FROM ("\
" SELECT setdatabase, pg_catalog.split_part(pg_catalog.unnest(setconfig),'=',1) conf"\
" FROM pg_db_role_setting "\
" ) s, pg_database d "\
" FROM pg_catalog.pg_db_role_setting "\
" ) s, pg_catalog.pg_database d "\
" WHERE s.setdatabase = d.oid "\
" AND conf LIKE '%s'"\
" AND d.datname LIKE '%s'"