Skip to content

Commit f5bea83

Browse files
committed
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
1 parent 61c8da5 commit f5bea83

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/bin/psql/describe.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2879,16 +2879,16 @@ describeOneTableDetails(const char *schemaname,
28792879
printfPQExpBuffer(&buf,
28802880
"SELECT oid, "
28812881
"stxrelid::pg_catalog.regclass, "
2882-
"stxnamespace::pg_catalog.regnamespace AS nsp, "
2882+
"stxnamespace::pg_catalog.regnamespace::pg_catalog.text AS nsp, "
28832883
"stxname,\n"
28842884
"pg_catalog.pg_get_statisticsobjdef_columns(oid) AS columns,\n"
28852885
" 'd' = any(stxkind) AS ndist_enabled,\n"
28862886
" 'f' = any(stxkind) AS deps_enabled,\n"
28872887
" 'm' = any(stxkind) AS mcv_enabled,\n"
28882888
"stxstattarget\n"
2889-
"FROM pg_catalog.pg_statistic_ext stat\n"
2889+
"FROM pg_catalog.pg_statistic_ext\n"
28902890
"WHERE stxrelid = '%s'\n"
2891-
"ORDER BY 1;",
2891+
"ORDER BY nsp, stxname;",
28922892
oid);
28932893

28942894
result = PSQLexec(buf.data);
@@ -2990,7 +2990,7 @@ describeOneTableDetails(const char *schemaname,
29902990
appendPQExpBufferStr(&buf, " stxstattarget\n");
29912991
else
29922992
appendPQExpBufferStr(&buf, " -1 AS stxstattarget\n");
2993-
appendPQExpBuffer(&buf, "FROM pg_catalog.pg_statistic_ext stat\n"
2993+
appendPQExpBuffer(&buf, "FROM pg_catalog.pg_statistic_ext\n"
29942994
"WHERE stxrelid = '%s'\n"
29952995
"ORDER BY 1;",
29962996
oid);
@@ -4726,7 +4726,7 @@ listExtendedStats(const char *pattern)
47264726
initPQExpBuffer(&buf);
47274727
printfPQExpBuffer(&buf,
47284728
"SELECT \n"
4729-
"es.stxnamespace::pg_catalog.regnamespace::text AS \"%s\", \n"
4729+
"es.stxnamespace::pg_catalog.regnamespace::pg_catalog.text AS \"%s\", \n"
47304730
"es.stxname AS \"%s\", \n",
47314731
gettext_noop("Schema"),
47324732
gettext_noop("Name"));
@@ -4773,7 +4773,7 @@ listExtendedStats(const char *pattern)
47734773

47744774
processSQLNamePattern(pset.db, &buf, pattern,
47754775
false, false,
4776-
"es.stxnamespace::pg_catalog.regnamespace::text", "es.stxname",
4776+
"es.stxnamespace::pg_catalog.regnamespace::pg_catalog.text", "es.stxname",
47774777
NULL, "pg_catalog.pg_statistics_obj_is_visible(es.oid)");
47784778

47794779
appendPQExpBufferStr(&buf, "ORDER BY 1, 2;");

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy