| From: | Vismay Tiwari <vismay(dot)t(at)gmail(dot)com> |
|---|---|
| To: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
| Subject: | [PATCH v1] psql: schema-qualify catalog references in a tab-completion query |
| Date: | 2026-07-09 12:23:07 |
| Message-ID: | 20260709122307.3052-1-vismay.t@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
The tab-completion query behind Query_for_list_of_database_vars referenced
pg_db_role_setting and pg_database without schema qualification. A table of
the same name earlier in the user's search_path therefore shadows the catalog
and feeds arbitrary values into the completion suggestions for
"ALTER DATABASE ... RESET". Qualify both with pg_catalog, matching the
qualification already applied to unnest()/split_part() in this same query and
to the catalogs in the analogous subscription-variable completion query.
Reported-by: Zhou Digoal
Bug: #19523
Discussion: https://postgr.es/m/19523-424457118202f570@postgresql.org
---
Resending in-thread: my earlier copy of this patch reached the list without an
In-Reply-To header, so it landed unthreaded rather than under the report.
Same patch, no changes.
src/bin/psql/tab-complete.in.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c
index 49ea584..6a88470 100644
--- a/src/bin/psql/tab-complete.in.c
+++ b/src/bin/psql/tab-complete.in.c
@@ -1040,8 +1040,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'"
--
2.50.1 (Apple Git-155)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Ayush Tiwari | 2026-07-09 14:48:19 | Re: REVOKE's CASCADE protection doesn't work with INHERITed table owners |
| Previous Message | Vismay Tiwari | 2026-07-09 10:13:50 | Re: BUG #19523: psql tab-completion shadows pg_db_role_setting |