Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit fe594ab

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 a2ab9c0 commit fe594ab

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/bin/psql/describe.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -2608,16 +2608,16 @@ describeOneTableDetails(const char *schemaname,
26082608
printfPQExpBuffer(&buf,
26092609
"SELECT oid, "
26102610
"stxrelid::pg_catalog.regclass, "
2611-
"stxnamespace::pg_catalog.regnamespace AS nsp, "
2611+
"stxnamespace::pg_catalog.regnamespace::pg_catalog.text AS nsp, "
26122612
"stxname,\n"
26132613
"pg_catalog.pg_get_statisticsobjdef_columns(oid) AS columns,\n"
26142614
" 'd' = any(stxkind) AS ndist_enabled,\n"
26152615
" 'f' = any(stxkind) AS deps_enabled,\n"
26162616
" 'm' = any(stxkind) AS mcv_enabled,\n"
26172617
"stxstattarget\n"
2618-
"FROM pg_catalog.pg_statistic_ext stat\n"
2618+
"FROM pg_catalog.pg_statistic_ext\n"
26192619
"WHERE stxrelid = '%s'\n"
2620-
"ORDER BY 1;",
2620+
"ORDER BY nsp, stxname;",
26212621
oid);
26222622

26232623
result = PSQLexec(buf.data);
@@ -2719,7 +2719,7 @@ describeOneTableDetails(const char *schemaname,
27192719
appendPQExpBufferStr(&buf, " stxstattarget\n");
27202720
else
27212721
appendPQExpBufferStr(&buf, " -1 AS stxstattarget\n");
2722-
appendPQExpBuffer(&buf, "FROM pg_catalog.pg_statistic_ext stat\n"
2722+
appendPQExpBuffer(&buf, "FROM pg_catalog.pg_statistic_ext\n"
27232723
"WHERE stxrelid = '%s'\n"
27242724
"ORDER BY 1;",
27252725
oid);
@@ -4392,7 +4392,7 @@ listExtendedStats(const char *pattern)
43924392
initPQExpBuffer(&buf);
43934393
printfPQExpBuffer(&buf,
43944394
"SELECT \n"
4395-
"es.stxnamespace::pg_catalog.regnamespace::text AS \"%s\", \n"
4395+
"es.stxnamespace::pg_catalog.regnamespace::pg_catalog.text AS \"%s\", \n"
43964396
"es.stxname AS \"%s\", \n",
43974397
gettext_noop("Schema"),
43984398
gettext_noop("Name"));
@@ -4439,7 +4439,7 @@ listExtendedStats(const char *pattern)
44394439

44404440
processSQLNamePattern(pset.db, &buf, pattern,
44414441
false, false,
4442-
"es.stxnamespace::pg_catalog.regnamespace::text", "es.stxname",
4442+
"es.stxnamespace::pg_catalog.regnamespace::pg_catalog.text", "es.stxname",
44434443
NULL, "pg_catalog.pg_statistics_obj_is_visible(es.oid)");
44444444

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

0 commit comments

Comments
 (0)