pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Justin Pryzby <pryzby@telsasoft.com>
To: pgsql-hackers@lists.postgresql.org
Cc: Álvaro Herrera <alvherre@alvh.no-ip.org>
Cc: Tomas Vondra <tomas.vondra@enterprisedb.com>
Cc: Tatsuro Yamada <tatsuro.yamada.tf@nttcom.co.jp>
Subject: \dP and \dX use ::regclass without "pg_catalog."
Date: Fri, 27 Aug 2021 14:31:51 -0500
Message-ID: <20210827193151.GN26465@telsasoft.com> (raw)

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

Attachments:

  [text/x-diff] 0001-psql-dX-reference-regclass-with-pg_catalog.-prefix.patch (1.3K, ../20210827193151.GN26465@telsasoft.com/2-0001-psql-dX-reference-regclass-with-pg_catalog.-prefix.patch)
  download | inline diff:
From 70eb6d65084104fa54965a349474cda8db6ed90d Mon Sep 17 00:00:00 2001
From: Justin Pryzby <pryzbyj@telsasoft.com>
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

  [text/x-diff] 0002-psql-dP-reference-regclass-with-pg_catalog.-prefix.patch (1019B, ../20210827193151.GN26465@telsasoft.com/3-0002-psql-dP-reference-regclass-with-pg_catalog.-prefix.patch)
  download | inline diff:
From 9e243f51a095ec2ca5949d711483be2546e46d0e Mon Sep 17 00:00:00 2001
From: Justin Pryzby <pryzbyj@telsasoft.com>
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

view thread (10+ messages)  latest in thread

Message-ID: <20210827193151.GN26465@telsasoft.com>
Permalink:  ../20210827193151.GN26465@telsasoft.com/
Also on:    postgresql.org/message-id/20210827193151.GN26465@telsasoft.com

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: pryzby@telsasoft.com, pgsql-hackers@lists.postgresql.org, alvherre@alvh.no-ip.org, tomas.vondra@enterprisedb.com, tatsuro.yamada.tf@nttcom.co.jp
  Subject: Re: \dP and \dX use ::regclass without "pg_catalog."
  In-Reply-To: <20210827193151.GN26465@telsasoft.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox