diff options
author | Michael Paquier <michael@paquier.xyz> | 2022-01-08 16:45:14 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2022-01-08 16:45:14 +0900 |
commit | f5bea8360691eeaef7ad3b6163b3e2bbb9c7c466 (patch) | |
tree | 4541f471aa6b008302fbf6468606b2fcc0ea462e | |
parent | 61c8da50cb39ab41c3a7a0122d6943f72bb0798e (diff) | |
download | postgresql-f5bea8360691eeaef7ad3b6163b3e2bbb9c7c466.tar.gz postgresql-f5bea8360691eeaef7ad3b6163b3e2bbb9c7c466.zip |
Fix issues with describe queries of extended statistics in psql
This addresses some problems in the describe queries used for extended
statistics:
- Two schema qualifications for the text type were missing for \dX.
- The list of extended statistics listed for a table through \d was
ordered based on the object OIDs, but it is more consistent with the
other commands to order by namespace and then by object name.
- A couple of aliases were not used in \d. These are removed.
This is similar to commits 1f092a3 and 07f8a9e.
Author: Justin Pryzby
Discussion: https://postgr.es/m/20220107022235.GA14051@telsasoft.com
Backpatch-through: 14
-rw-r--r-- | src/bin/psql/describe.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index ac4247680c8..48348750ee3 100644 --- a/src/bin/psql/describe.c +++ b/src/bin/psql/describe.c @@ -2879,16 +2879,16 @@ 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" " '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 1;", + "ORDER BY nsp, stxname;", oid); result = PSQLexec(buf.data); @@ -2990,7 +2990,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); @@ -4726,7 +4726,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")); @@ -4773,7 +4773,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;"); |