Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1whnmv-000QfR-2K for pgsql-bugs@arkaria.postgresql.org; Thu, 09 Jul 2026 12:23:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1whnmt-00D1qq-27 for pgsql-bugs@arkaria.postgresql.org; Thu, 09 Jul 2026 12:23:32 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1whnmt-00D1qi-1M for pgsql-bugs@lists.postgresql.org; Thu, 09 Jul 2026 12:23:32 +0000 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1whnmq-00000000Jft-3o1o for pgsql-bugs@lists.postgresql.org; Thu, 09 Jul 2026 12:23:31 +0000 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-2cacb8416a1so15773375ad.1 for ; Thu, 09 Jul 2026 05:23:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783599808; x=1784204608; darn=lists.postgresql.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=A/ncnSIkmj1CUgLuYYL4g5m64pmI80L+P1xyNSvCenY=; b=K+cqgl2fb2UHjJ9oFHv0nqiaoRFHLvpubA91cMvvan0QHrmcHEjt5Q5vVo9sscRw5M hM6p9ZSgtPqSRm9pbaz8wKHb4v/rRbs7HMSLqaweqejwz2wUl/MtmgUryD5tdqO/V9zT BcfYCjHmwRXm40B7J/o5MuH8X4w5afljZdVJTKvL2HClLiwSB9Z8v9f1zCo0/KActd4o hHgjd/kkwIvBnJ6n742EaU3d2hsV+CCijBPSsFkB2C2Us2v8/N5sLY7FY1qAkbGsQugH iHxW19nCvPKMhn8qatYJEpEnMmQYj9OlmjA/bJmT38ZCe6n17DRzPu31jBDzj/PTDBtY T+Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783599808; x=1784204608; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=A/ncnSIkmj1CUgLuYYL4g5m64pmI80L+P1xyNSvCenY=; b=sVtRZubyRTMBgGmO8uUIUXhHFqjb94DAVMP7Z8CLLL3jb5satc+cG/NTz9F/ABVoFE 3qSf6Wn8CbEZcNZxZtSltTA5AWunjlfye03UBYu/bKd7vSaNNurqeX20nCsXt71Goez4 KlWdl9k9qcllTbTEfhd4tMj9nxY7V/bRm6wF128smCAKy7pwl3ZGH8ZRjXeZ4zQBHY4Y qT0iPygdHmj/uK0vkUv0EIXa5rtvKISD85J8EnCu4XxvouxsLdscnOIe8jjlQoExo5IQ p6rgbY5QzzplbsLgOC8axL6Hinp8afGtrSfcIlAfpj6HWsOdccKxBKr2dzPE2f424rlk VzGA== X-Gm-Message-State: AOJu0Yw23XFZMOzAWI7tif7+L2+T6ybaMbRo5hobr5z4vUcl3mv+80ef WEOFDYuE19TazpCkVJQk1kk0iRyc7wyq3bajcN3zxBctImfEc/GE1KWLzB4aL9Ui X-Gm-Gg: AfdE7cn833uXMAb0LzoV+i7R9LV6utQxM5vouR0cEwLj64qV4fjbkqJ6xjCr38DB/Ml L3i3vTcisCZDXcpD/ai/ONWKiP5mq3d1me6XyKC1g9XumGCxUjw0dPgQXnL/YK+HovRcUZ3xFP+ jY0GA75kolx2OOg1iJh+7PRzAN1l2kjY++AbFI8lnp9AcdzD5mckiHNmV9hONhveJ9ukR/pr9rV gxkfeBK00BmAfGdL7gA16wRcJOBvqt/t+7OaxkITA1BVTUF2R0LaocDLjVICisSaRzqmi0aMt/N DxLIGkTWR6BzKrQ7WBJe9+Zs1MZTMdEj9MI8CFongdQm5cV0nyU/9lpxUpuukW4x+fDevdJQUam nrlM1wDh6Tkd8xdQkwKmoO3dNEUXSd3Pz8FrFLedryvn7dgEpv+Vw3my/vkyob3Bsb0EZq60TrK WRzvcojkUbgS9hD2M358QOybtTZzP1WgCxUWE/zQ== X-Received: by 2002:a05:6a21:a49:b0:3bf:9a30:3a12 with SMTP id adf61e73a8af0-3c0bd1d8b2fmr8145508637.50.1783599808180; Thu, 09 Jul 2026 05:23:28 -0700 (PDT) Received: from localhost.localdomain ([223.181.42.95]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-13b659fa13bsm29604026c88.15.2026.07.09.05.23.26 for (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 09 Jul 2026 05:23:27 -0700 (PDT) From: Vismay Tiwari To: pgsql-bugs@lists.postgresql.org Subject: [PATCH v1] psql: schema-qualify catalog references in a tab-completion query Date: Thu, 9 Jul 2026 17:53:07 +0530 Message-ID: <20260709122307.3052-1-vismay.t@gmail.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <19523-424457118202f570@postgresql.org> References: <19523-424457118202f570@postgresql.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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)