Commit 20c95f27 authored by Tom Lane's avatar Tom Lane

Clean up psql/describe.c's messy query for extended stats.

Remove unnecessary casts, safely schema-qualify the ones that remain,
lose an unnecessary level of sub-SELECT, reformat for tidiness.
parent e6c9a5a9
...@@ -2343,14 +2343,17 @@ describeOneTableDetails(const char *schemaname, ...@@ -2343,14 +2343,17 @@ describeOneTableDetails(const char *schemaname,
if (pset.sversion >= 100000) if (pset.sversion >= 100000)
{ {
printfPQExpBuffer(&buf, printfPQExpBuffer(&buf,
"SELECT oid, stanamespace::regnamespace AS nsp, staname, stakeys,\n" "SELECT oid, "
" (SELECT pg_catalog.string_agg(pg_catalog.quote_ident(attname::text),', ') \n" "stanamespace::pg_catalog.regnamespace AS nsp, "
" FROM ((SELECT pg_catalog.unnest(stakeys) AS attnum) s\n" "staname, stakeys,\n"
" (SELECT pg_catalog.string_agg(pg_catalog.quote_ident(attname),', ')\n"
" FROM pg_catalog.unnest(stakeys) s(attnum)\n"
" JOIN pg_catalog.pg_attribute a ON (starelid = a.attrelid AND\n" " JOIN pg_catalog.pg_attribute a ON (starelid = a.attrelid AND\n"
"a.attnum = s.attnum AND not attisdropped))) AS columns,\n" " a.attnum = s.attnum AND NOT attisdropped)) AS columns,\n"
" (staenabled::char[] @> '{d}'::char[]) AS ndist_enabled,\n" " (staenabled @> '{d}') AS ndist_enabled,\n"
" (staenabled::char[] @> '{f}'::char[]) AS deps_enabled\n" " (staenabled @> '{f}') AS deps_enabled\n"
"FROM pg_catalog.pg_statistic_ext stat WHERE starelid = '%s'\n" "FROM pg_catalog.pg_statistic_ext stat "
"WHERE starelid = '%s'\n"
"ORDER BY 1;", "ORDER BY 1;",
oid); oid);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment