pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Justin Pryzby <pryzby@telsasoft.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: Tatsuro Yamada <tatsuro.yamada.tf@nttcom.co.jp>
Cc: Álvaro Herrera <alvherre@alvh.no-ip.org>
Cc: Magnus Hagander <magnus@hagander.net>
Cc: pgsql-hackers@lists.postgresql.org, Tomas Vondra <tomas.vondra@enterprisedb.com>
Cc: pgsql-hackers@postgresql.org, Alvaro Herrera <alvherre@2ndquadrant.com>
Subject: Re: \dP and \dX use ::regclass without "pg_catalog."
Date: Fri, 7 Jan 2022 15:56:20 -0600
Message-ID: <20220107215620.GH14051@telsasoft.com> (raw)
In-Reply-To: <YdgfSW/fSjDC/742@paquier.xyz>
References: <20220107022235.GA14051@telsasoft.com>
	<1b7d4248-a96d-6e5c-bde9-d7d5584e7448@nttcom.co.jp>
	<YdgfSW/fSjDC/742@paquier.xyz>

On Fri, Jan 07, 2022 at 08:08:57PM +0900, Michael Paquier wrote:
> On Fri, Jan 07, 2022 at 06:30:30PM +0900, Tatsuro Yamada wrote:
> > We should prefix them with pg_catalog as well.
> > Are you planning to make a patch?
> > If not, I'll make a patch later since that's where \dX is.
> 
> If any of you can make a patch, that would be great.  Thanks!

I'd propose these.

Attachments:

  [text/x-diff] 0001-psql-qualify-text-with-pg_catalog.patch (1.2K, ../20220107215620.GH14051@telsasoft.com/2-0001-psql-qualify-text-with-pg_catalog.patch)
  download | inline diff:
From d1e337daf81faa9a0a8c33a26091cbae396df7bb Mon Sep 17 00:00:00 2001
From: Justin Pryzby <pryzbyj@telsasoft.com>
Date: Thu, 6 Jan 2022 20:23:52 -0600
Subject: [PATCH 1/3] psql: qualify ::text with pg_catalog

backpatch to v14
---
 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 7cbf5f7b105..b3fbff1a0c3 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -4392,7 +4392,7 @@ listExtendedStats(const char *pattern)
 	initPQExpBuffer(&buf);
 	printfPQExpBuffer(&buf,
 					  "SELECT \n"
-					  "es.stxnamespace::pg_catalog.regnamespace::text AS \"%s\", \n"
+					  "es.stxnamespace::pg_catalog.regnamespace::pg_catalog.text AS \"%s\", \n"
 					  "es.stxname AS \"%s\", \n",
 					  gettext_noop("Schema"),
 					  gettext_noop("Name"));
@@ -4439,7 +4439,7 @@ listExtendedStats(const char *pattern)
 
 	processSQLNamePattern(pset.db, &buf, pattern,
 						  false, false,
-						  "es.stxnamespace::pg_catalog.regnamespace::text", "es.stxname",
+						  "es.stxnamespace::pg_catalog.regnamespace::pg_catalog.text", "es.stxname",
 						  NULL, "pg_catalog.pg_statistics_obj_is_visible(es.oid)");
 
 	appendPQExpBufferStr(&buf, "ORDER BY 1, 2;");
-- 
2.17.1

  [text/x-diff] 0002-psql-order-a-relation-s-extended-statistics-by-name.patch (1.2K, ../20220107215620.GH14051@telsasoft.com/3-0002-psql-order-a-relation-s-extended-statistics-by-name.patch)
  download | inline diff:
From 5033095abb3631bf01e4213752d5a4d3a24896fa Mon Sep 17 00:00:00 2001
From: Justin Pryzby <pryzbyj@telsasoft.com>
Date: Thu, 6 Jan 2022 20:25:07 -0600
Subject: [PATCH 2/3] psql: order a relation's extended statistics by name..

like \dX

not by OID

v15 only?
---
 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 b3fbff1a0c3..daf06bbcc81 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -2608,7 +2608,7 @@ describeOneTableDetails(const char *schemaname,
 			printfPQExpBuffer(&buf,
 							  "SELECT oid, "
 							  "stxrelid::pg_catalog.regclass, "
-							  "stxnamespace::pg_catalog.regnamespace AS nsp, "
+							  "stxnamespace::pg_catalog.regnamespace::pg_catalog.text AS nsp, "
 							  "stxname,\n"
 							  "pg_catalog.pg_get_statisticsobjdef_columns(oid) AS columns,\n"
 							  "  'd' = any(stxkind) AS ndist_enabled,\n"
@@ -2617,7 +2617,7 @@ describeOneTableDetails(const char *schemaname,
 							  "stxstattarget\n"
 							  "FROM pg_catalog.pg_statistic_ext stat\n"
 							  "WHERE stxrelid = '%s'\n"
-							  "ORDER BY 1;",
+							  "ORDER BY nsp, stxname;",
 							  oid);
 
 			result = PSQLexec(buf.data);
-- 
2.17.1

  [text/x-diff] 0003-Remove-unused-table-alias.patch (1.2K, ../20220107215620.GH14051@telsasoft.com/4-0003-Remove-unused-table-alias.patch)
  download | inline diff:
From 020f425c7ed67183275d64f19c34f69d63b8ddc6 Mon Sep 17 00:00:00 2001
From: Justin Pryzby <pryzbyj@telsasoft.com>
Date: Fri, 7 Jan 2022 15:48:46 -0600
Subject: [PATCH 3/3] Remove unused table alias

---
 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 daf06bbcc81..c62d3bd4f8a 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -2615,7 +2615,7 @@ describeOneTableDetails(const char *schemaname,
 							  "  'f' = any(stxkind) AS deps_enabled,\n"
 							  "  'm' = any(stxkind) AS mcv_enabled,\n"
 							  "stxstattarget\n"
-							  "FROM pg_catalog.pg_statistic_ext stat\n"
+							  "FROM pg_catalog.pg_statistic_ext\n"
 							  "WHERE stxrelid = '%s'\n"
 							  "ORDER BY nsp, stxname;",
 							  oid);
@@ -2719,7 +2719,7 @@ describeOneTableDetails(const char *schemaname,
 				appendPQExpBufferStr(&buf, "  stxstattarget\n");
 			else
 				appendPQExpBufferStr(&buf, "  -1 AS stxstattarget\n");
-			appendPQExpBuffer(&buf, "FROM pg_catalog.pg_statistic_ext stat\n"
+			appendPQExpBuffer(&buf, "FROM pg_catalog.pg_statistic_ext\n"
 							  "WHERE stxrelid = '%s'\n"
 							  "ORDER BY 1;",
 							  oid);
-- 
2.17.1

view thread (10+ messages)  latest in thread

Message-ID: <20220107215620.GH14051@telsasoft.com>
Permalink:  ../20220107215620.GH14051@telsasoft.com/
Also on:    postgresql.org/message-id/20220107215620.GH14051@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, michael@paquier.xyz, tatsuro.yamada.tf@nttcom.co.jp, alvherre@alvh.no-ip.org, magnus@hagander.net, tomas.vondra@enterprisedb.com, alvherre@2ndquadrant.com
  Subject: Re: \dP and \dX use ::regclass without "pg_catalog."
  In-Reply-To: <20220107215620.GH14051@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