Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mJha4-00044p-NF for pgsql-hackers@arkaria.postgresql.org; Fri, 27 Aug 2021 19:32:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mJha3-0007MY-Nj for pgsql-hackers@arkaria.postgresql.org; Fri, 27 Aug 2021 19:31:59 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mJha3-0007MQ-BJ for pgsql-hackers@lists.postgresql.org; Fri, 27 Aug 2021 19:31:59 +0000 Received: from mail-io1-xd30.google.com ([2607:f8b0:4864:20::d30]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mJhZy-0003KD-D9 for pgsql-hackers@lists.postgresql.org; Fri, 27 Aug 2021 19:31:58 +0000 Received: by mail-io1-xd30.google.com with SMTP id g9so9874972ioq.11 for ; Fri, 27 Aug 2021 12:31:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=wjYqPpiVpfvHN7W1vXxQFTBXgQMNTo4JG3ncL6rtNSk=; b=oYOrDoLkDuRhviuHqQq/You+TpUTDGSJemPCcbrimNqAaYshFDdVlGVU6CSlYB5nPl sh9cdfqk2zNohpASJVjR+IvH0kqKcSltXHTvTs4MjOBtyVrSVknAb3exdP77WqUxUxTk Mfoib4ejvbSqQiYru+JWBlGZeOMvB4bxb/gH3485s8H8hVNtGnLh6v6VcyiBPDVbol92 62UUxdH2muV5St4PlZhR/PX/9LKHvqtScJAS3FNYLlOLi9bO7n1lwJUweaZaWMhZBxOd gn776D/LHhQGe0mVszLS+I6tnwy31zqMO6lCwb+aZbagCk130ZatgPI/gukL3HvknXON ONWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=wjYqPpiVpfvHN7W1vXxQFTBXgQMNTo4JG3ncL6rtNSk=; b=dKHtOM9tGnYRLuxnynKIsJEo+WwLxLC0ZjyCDqpco6gWJOZZMcXDvV0dsVFfuMtJyy HyoFFJwE0+GLK0cRzeghDxMlUCVqWQeNupdj8UOgnGB8yNQIlOuNhtIXPXlBe3KOGsjl UVBbDoagomlsITwSObQdH67xuXjrnrLuBX6IufZoFYhoSJQhXBWxjNWPFQ9D7LMSbu3I baHEIeEu8/ABm6zfuhokJNkbh0lqShziU6c0VaAl/+/B18q2BZlEfaLkCW/pdTPzG5nw y9tZRCfYErNop5F5IWMWmmqO48dUO3cGvOQwQwFSoD4/HFHrAUARvA798NJ8UUkP7caS NpyA== X-Gm-Message-State: AOAM532Jpm+dDlVLcbNqKv6u6MZmwZamy/4YJd8G6h811Muqoew0CwGS EAUQRx0rTl0CvLxih5MSgaRALA== X-Google-Smtp-Source: ABdhPJwkUs+nXadFXLXM9MnNF6PxVtRxfD4cKqr7paGUG1tLIgO02V4rnDINh4XluAbuYpNHhq6cZQ== X-Received: by 2002:a6b:e905:: with SMTP id u5mr8721702iof.116.1630092713183; Fri, 27 Aug 2021 12:31:53 -0700 (PDT) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id f5sm4066995ils.3.2021.08.27.12.31.52 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Aug 2021 12:31:52 -0700 (PDT) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 67474800A39; Fri, 27 Aug 2021 14:31:51 -0500 (CDT) Date: Fri, 27 Aug 2021 14:31:51 -0500 From: Justin Pryzby To: pgsql-hackers@lists.postgresql.org Cc: =?iso-8859-1?Q?=C1lvaro?= Herrera , Tomas Vondra , Tatsuro Yamada Subject: \dP and \dX use ::regclass without "pg_catalog." Message-ID: <20210827193151.GN26465@telsasoft.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="tsOsTdHNUZQcU9Ye" Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --tsOsTdHNUZQcU9Ye Content-Type: text/plain; charset=us-ascii Content-Disposition: inline I noticed that for \dP+ since 1c5d9270e, regclass is written without "pg_catalog." (Alvaro and I failed to notice it in 421a2c483, too). + if (showNested || pattern) + appendPQExpBuffer(&buf, + ",\n c3.oid::regclass as \"%s\"", + gettext_noop("Parent name")); + + if (showIndexes) + appendPQExpBuffer(&buf, + ",\n c2.oid::regclass as \"%s\"", + gettext_noop("On table")); \dX is new in v14, and introduced the same issue in ad600bba0 (and modifies it but not fixed in a4d75c86). I searched for issues like this, which finds all 4 errors with 1 false positive in psql/describe.c |time grep -wF "$(grep -oE 'pg_catalog\.[_[:alpha:]]+' src/bin/psql/describe.c |sed -r 's/^pg_catalog\.//; /^(char|oid|text|trigger)$/d' )" src/bin/psql/describe.c |grep -Ev 'pg_catalog\.|^ *[/ ]\*' |#include "catalog/pg_am.h" | ",\n inh.inhparent::regclass as \"%s\"", | ",\n c2.oid::regclass as \"%s\"", | " es.stxrelid::regclass) AS \"%s\"", | "es.stxrelid::regclass) AS \"%s\"", Tom informs me that this is not considered to be interesting as a security patch. -- Justin --tsOsTdHNUZQcU9Ye Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-psql-dX-reference-regclass-with-pg_catalog.-prefix.patch" From 70eb6d65084104fa54965a349474cda8db6ed90d Mon Sep 17 00:00:00 2001 From: Justin Pryzby Date: Fri, 27 Aug 2021 13:52:39 -0500 Subject: [PATCH 1/2] psql \dX: reference regclass with "pg_catalog." prefix Should backpatch to v14 See similar issue fixed at 1d21ba8a9b8cb784f927a2c9c5818f8ff6779c0b. --- src/bin/psql/describe.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 8333558bda..772d881c2f 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -4735,7 +4735,7 @@ listExtendedStats(const char *pattern) appendPQExpBuffer(&buf, "pg_catalog.format('%%s FROM %%s', \n" " pg_get_statisticsobjdef_columns(es.oid), \n" - " es.stxrelid::regclass) AS \"%s\"", + " es.stxrelid::pg_catalog.regclass) AS \"%s\"", gettext_noop("Definition")); else appendPQExpBuffer(&buf, @@ -4746,7 +4746,7 @@ listExtendedStats(const char *pattern) " ON (es.stxrelid = a.attrelid \n" " AND a.attnum = s.attnum \n" " AND NOT a.attisdropped)), \n" - "es.stxrelid::regclass) AS \"%s\"", + "es.stxrelid::pg_catalog.regclass) AS \"%s\"", gettext_noop("Definition")); appendPQExpBuffer(&buf, -- 2.17.0 --tsOsTdHNUZQcU9Ye Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0002-psql-dP-reference-regclass-with-pg_catalog.-prefix.patch" From 9e243f51a095ec2ca5949d711483be2546e46d0e Mon Sep 17 00:00:00 2001 From: Justin Pryzby Date: Fri, 27 Aug 2021 13:52:15 -0500 Subject: [PATCH 2/2] psql \dP: reference regclass with "pg_catalog." prefix Should backpatch to v12 --- src/bin/psql/describe.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 772d881c2f..30fb17123e 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -4275,12 +4275,12 @@ listPartitionedTables(const char *reltypes, const char *pattern, bool verbose) if (showNested || pattern) appendPQExpBuffer(&buf, - ",\n inh.inhparent::regclass as \"%s\"", + ",\n inh.inhparent::pg_catalog.regclass as \"%s\"", gettext_noop("Parent name")); if (showIndexes) appendPQExpBuffer(&buf, - ",\n c2.oid::regclass as \"%s\"", + ",\n c2.oid::pg_catalog.regclass as \"%s\"", gettext_noop("Table")); if (verbose) -- 2.17.0 --tsOsTdHNUZQcU9Ye--