public inbox for [email protected]
help / color / mirror / Atom feedFrom: Matheus Alcantara <[email protected]>
To: [email protected]
Subject: psql: Add verbose option (+) for \dX command
Date: Thu, 19 Feb 2026 12:38:06 -0300
Message-ID: <[email protected]> (raw)
Hi,
While I was reviewing another patch I noticed that we don't have the
verbose option(+) on \dX command to get extended statistics comments.
Althrought comments can be obtained using obj_description() perhaps it
can be useful to have a verbose option on \dX to get this information.
Thoughts?
--
Matheus Alcantara
EDB: https://www.enterprisedb.com
From 9786d573faa048f0ba705a12a249652c704d26a4 Mon Sep 17 00:00:00 2001
From: Matheus Alcantara <[email protected]>
Date: Thu, 19 Feb 2026 10:55:00 -0300
Subject: [PATCH v1] psql: Add verbose option (+) for \dX command
---
src/bin/psql/command.c | 2 +-
src/bin/psql/describe.c | 11 ++++++++---
src/bin/psql/describe.h | 2 +-
src/bin/psql/help.c | 2 +-
4 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index 213d48500de..3412b0e3d28 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -1277,7 +1277,7 @@ exec_command_d(PsqlScanState scan_state, bool active_branch, const char *cmd)
success = listExtensions(pattern);
break;
case 'X': /* Extended Statistics */
- success = listExtendedStats(pattern);
+ success = listExtendedStats(pattern, show_verbose);
break;
case 'y': /* Event Triggers */
success = listEventTriggers(pattern, show_verbose);
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 3584c4e1428..9fc3c5f9ad4 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -4890,7 +4890,7 @@ listEventTriggers(const char *pattern, bool verbose)
* Describes extended statistics.
*/
bool
-listExtendedStats(const char *pattern)
+listExtendedStats(const char *pattern, bool verbose)
{
PQExpBufferData buf;
PGresult *res;
@@ -4947,12 +4947,17 @@ listExtendedStats(const char *pattern)
{
appendPQExpBuffer(&buf,
",\nCASE WHEN " CppAsString2(STATS_EXT_MCV) " = any(es.stxkind) THEN 'defined' \n"
- "END AS \"%s\" ",
+ "END AS \"%s\"",
gettext_noop("MCV"));
}
+ if (verbose)
+ appendPQExpBuffer(&buf,
+ ",\npg_catalog.obj_description(es.oid, 'pg_statistic_ext') AS \"%s\"",
+ gettext_noop("Description"));
+
appendPQExpBufferStr(&buf,
- " \nFROM pg_catalog.pg_statistic_ext es \n");
+ "\nFROM pg_catalog.pg_statistic_ext es\n");
if (!validateSQLNamePattern(&buf, pattern,
false, false,
diff --git a/src/bin/psql/describe.h b/src/bin/psql/describe.h
index b60a2ad0e14..47fae5ceafb 100644
--- a/src/bin/psql/describe.h
+++ b/src/bin/psql/describe.h
@@ -114,7 +114,7 @@ extern bool listExtensions(const char *pattern);
extern bool listExtensionContents(const char *pattern);
/* \dX */
-extern bool listExtendedStats(const char *pattern);
+extern bool listExtendedStats(const char *pattern, bool verbose);
/* \dy */
extern bool listEventTriggers(const char *pattern, bool verbose);
diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c
index dfd9dd73078..bcfdbbba571 100644
--- a/src/bin/psql/help.c
+++ b/src/bin/psql/help.c
@@ -267,7 +267,7 @@ slashUsage(unsigned short int pager)
HELP0(" \\du[Sx+] [PATTERN] list roles\n");
HELP0(" \\dv[Sx+] [PATTERN] list views\n");
HELP0(" \\dx[x+] [PATTERN] list extensions\n");
- HELP0(" \\dX[x] [PATTERN] list extended statistics\n");
+ HELP0(" \\dX[x+] [PATTERN] list extended statistics\n");
HELP0(" \\dy[x+] [PATTERN] list event triggers\n");
HELP0(" \\l[x+] [PATTERN] list databases\n");
HELP0(" \\sf[+] FUNCNAME show a function's definition\n");
--
2.52.0
Attachments:
[text/plain] v1-0001-psql-Add-verbose-option-for-dX-command.patch (3.1K, ../[email protected]/2-v1-0001-psql-Add-verbose-option-for-dX-command.patch)
download | inline diff:
From 9786d573faa048f0ba705a12a249652c704d26a4 Mon Sep 17 00:00:00 2001
From: Matheus Alcantara <[email protected]>
Date: Thu, 19 Feb 2026 10:55:00 -0300
Subject: [PATCH v1] psql: Add verbose option (+) for \dX command
---
src/bin/psql/command.c | 2 +-
src/bin/psql/describe.c | 11 ++++++++---
src/bin/psql/describe.h | 2 +-
src/bin/psql/help.c | 2 +-
4 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c
index 213d48500de..3412b0e3d28 100644
--- a/src/bin/psql/command.c
+++ b/src/bin/psql/command.c
@@ -1277,7 +1277,7 @@ exec_command_d(PsqlScanState scan_state, bool active_branch, const char *cmd)
success = listExtensions(pattern);
break;
case 'X': /* Extended Statistics */
- success = listExtendedStats(pattern);
+ success = listExtendedStats(pattern, show_verbose);
break;
case 'y': /* Event Triggers */
success = listEventTriggers(pattern, show_verbose);
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 3584c4e1428..9fc3c5f9ad4 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -4890,7 +4890,7 @@ listEventTriggers(const char *pattern, bool verbose)
* Describes extended statistics.
*/
bool
-listExtendedStats(const char *pattern)
+listExtendedStats(const char *pattern, bool verbose)
{
PQExpBufferData buf;
PGresult *res;
@@ -4947,12 +4947,17 @@ listExtendedStats(const char *pattern)
{
appendPQExpBuffer(&buf,
",\nCASE WHEN " CppAsString2(STATS_EXT_MCV) " = any(es.stxkind) THEN 'defined' \n"
- "END AS \"%s\" ",
+ "END AS \"%s\"",
gettext_noop("MCV"));
}
+ if (verbose)
+ appendPQExpBuffer(&buf,
+ ",\npg_catalog.obj_description(es.oid, 'pg_statistic_ext') AS \"%s\"",
+ gettext_noop("Description"));
+
appendPQExpBufferStr(&buf,
- " \nFROM pg_catalog.pg_statistic_ext es \n");
+ "\nFROM pg_catalog.pg_statistic_ext es\n");
if (!validateSQLNamePattern(&buf, pattern,
false, false,
diff --git a/src/bin/psql/describe.h b/src/bin/psql/describe.h
index b60a2ad0e14..47fae5ceafb 100644
--- a/src/bin/psql/describe.h
+++ b/src/bin/psql/describe.h
@@ -114,7 +114,7 @@ extern bool listExtensions(const char *pattern);
extern bool listExtensionContents(const char *pattern);
/* \dX */
-extern bool listExtendedStats(const char *pattern);
+extern bool listExtendedStats(const char *pattern, bool verbose);
/* \dy */
extern bool listEventTriggers(const char *pattern, bool verbose);
diff --git a/src/bin/psql/help.c b/src/bin/psql/help.c
index dfd9dd73078..bcfdbbba571 100644
--- a/src/bin/psql/help.c
+++ b/src/bin/psql/help.c
@@ -267,7 +267,7 @@ slashUsage(unsigned short int pager)
HELP0(" \\du[Sx+] [PATTERN] list roles\n");
HELP0(" \\dv[Sx+] [PATTERN] list views\n");
HELP0(" \\dx[x+] [PATTERN] list extensions\n");
- HELP0(" \\dX[x] [PATTERN] list extended statistics\n");
+ HELP0(" \\dX[x+] [PATTERN] list extended statistics\n");
HELP0(" \\dy[x+] [PATTERN] list event triggers\n");
HELP0(" \\l[x+] [PATTERN] list databases\n");
HELP0(" \\sf[+] FUNCNAME show a function's definition\n");
--
2.52.0
view thread (2+ messages)
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: [email protected]
Cc: [email protected], [email protected]
Subject: Re: psql: Add verbose option (+) for \dX command
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox