aboutsummaryrefslogtreecommitdiff
path: root/src/bin/psql/describe.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/psql/describe.c')
-rw-r--r--src/bin/psql/describe.c100
1 files changed, 63 insertions, 37 deletions
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 2084f5ccdac..99e28f607e8 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -923,38 +923,52 @@ listAllDbs(const char *pattern, bool verbose)
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf,
- "SELECT d.datname as \"%s\",\n"
- " pg_catalog.pg_get_userbyid(d.datdba) as \"%s\",\n"
- " pg_catalog.pg_encoding_to_char(d.encoding) as \"%s\",\n"
- " d.datcollate as \"%s\",\n"
- " d.datctype as \"%s\",\n",
+ "SELECT\n"
+ " d.datname as \"%s\",\n"
+ " pg_catalog.pg_get_userbyid(d.datdba) as \"%s\",\n"
+ " pg_catalog.pg_encoding_to_char(d.encoding) as \"%s\",\n",
gettext_noop("Name"),
gettext_noop("Owner"),
- gettext_noop("Encoding"),
- gettext_noop("Collate"),
- gettext_noop("Ctype"));
+ gettext_noop("Encoding"));
if (pset.sversion >= 150000)
appendPQExpBuffer(&buf,
- " d.daticulocale as \"%s\",\n"
- " CASE d.datlocprovider WHEN 'c' THEN 'libc' WHEN 'i' THEN 'icu' END AS \"%s\",\n",
- gettext_noop("ICU Locale"),
+ " CASE d.datlocprovider WHEN 'c' THEN 'libc' WHEN 'i' THEN 'icu' END AS \"%s\",\n",
gettext_noop("Locale Provider"));
else
appendPQExpBuffer(&buf,
- " NULL as \"%s\",\n"
- " 'libc' AS \"%s\",\n",
- gettext_noop("ICU Locale"),
+ " 'libc' AS \"%s\",\n",
gettext_noop("Locale Provider"));
- appendPQExpBufferStr(&buf, " ");
+ appendPQExpBuffer(&buf,
+ " d.datcollate as \"%s\",\n"
+ " d.datctype as \"%s\",\n",
+ gettext_noop("Collate"),
+ gettext_noop("Ctype"));
+ if (pset.sversion >= 150000)
+ appendPQExpBuffer(&buf,
+ " d.daticulocale as \"%s\",\n",
+ gettext_noop("ICU Locale"));
+ else
+ appendPQExpBuffer(&buf,
+ " NULL as \"%s\",\n",
+ gettext_noop("ICU Locale"));
+ if (pset.sversion >= 160000)
+ appendPQExpBuffer(&buf,
+ " d.daticurules as \"%s\",\n",
+ gettext_noop("ICU Rules"));
+ else
+ appendPQExpBuffer(&buf,
+ " NULL as \"%s\",\n",
+ gettext_noop("ICU Rules"));
+ appendPQExpBufferStr(&buf, " ");
printACLColumn(&buf, "d.datacl");
if (verbose)
appendPQExpBuffer(&buf,
- ",\n CASE WHEN pg_catalog.has_database_privilege(d.datname, 'CONNECT')\n"
- " THEN pg_catalog.pg_size_pretty(pg_catalog.pg_database_size(d.datname))\n"
- " ELSE 'No Access'\n"
- " END as \"%s\""
- ",\n t.spcname as \"%s\""
- ",\n pg_catalog.shobj_description(d.oid, 'pg_database') as \"%s\"",
+ ",\n CASE WHEN pg_catalog.has_database_privilege(d.datname, 'CONNECT')\n"
+ " THEN pg_catalog.pg_size_pretty(pg_catalog.pg_database_size(d.datname))\n"
+ " ELSE 'No Access'\n"
+ " END as \"%s\""
+ ",\n t.spcname as \"%s\""
+ ",\n pg_catalog.shobj_description(d.oid, 'pg_database') as \"%s\"",
gettext_noop("Size"),
gettext_noop("Tablespace"),
gettext_noop("Description"));
@@ -4849,52 +4863,64 @@ listCollations(const char *pattern, bool verbose, bool showSystem)
PQExpBufferData buf;
PGresult *res;
printQueryOpt myopt = pset.popt;
- static const bool translate_columns[] = {false, false, false, false, false, false, true, false};
+ static const bool translate_columns[] = {false, false, false, false, false, false, false, true, false};
initPQExpBuffer(&buf);
printfPQExpBuffer(&buf,
- "SELECT n.nspname AS \"%s\",\n"
- " c.collname AS \"%s\",\n"
- " c.collcollate AS \"%s\",\n"
- " c.collctype AS \"%s\"",
+ "SELECT\n"
+ " n.nspname AS \"%s\",\n"
+ " c.collname AS \"%s\",\n",
gettext_noop("Schema"),
- gettext_noop("Name"),
+ gettext_noop("Name"));
+
+ if (pset.sversion >= 100000)
+ appendPQExpBuffer(&buf,
+ " CASE c.collprovider WHEN 'd' THEN 'default' WHEN 'c' THEN 'libc' WHEN 'i' THEN 'icu' END AS \"%s\",\n",
+ gettext_noop("Provider"));
+ else
+ appendPQExpBuffer(&buf,
+ " 'libc' AS \"%s\",\n",
+ gettext_noop("Provider"));
+
+ appendPQExpBuffer(&buf,
+ " c.collcollate AS \"%s\",\n"
+ " c.collctype AS \"%s\",\n",
gettext_noop("Collate"),
gettext_noop("Ctype"));
if (pset.sversion >= 150000)
appendPQExpBuffer(&buf,
- ",\n c.colliculocale AS \"%s\"",
+ " c.colliculocale AS \"%s\",\n",
gettext_noop("ICU Locale"));
else
appendPQExpBuffer(&buf,
- ",\n c.collcollate AS \"%s\"",
+ " c.collcollate AS \"%s\",\n",
gettext_noop("ICU Locale"));
- if (pset.sversion >= 100000)
+ if (pset.sversion >= 160000)
appendPQExpBuffer(&buf,
- ",\n CASE c.collprovider WHEN 'd' THEN 'default' WHEN 'c' THEN 'libc' WHEN 'i' THEN 'icu' END AS \"%s\"",
- gettext_noop("Provider"));
+ " c.collicurules AS \"%s\",\n",
+ gettext_noop("ICU Rules"));
else
appendPQExpBuffer(&buf,
- ",\n 'libc' AS \"%s\"",
- gettext_noop("Provider"));
+ " NULL AS \"%s\",\n",
+ gettext_noop("ICU Rules"));
if (pset.sversion >= 120000)
appendPQExpBuffer(&buf,
- ",\n CASE WHEN c.collisdeterministic THEN '%s' ELSE '%s' END AS \"%s\"",
+ " CASE WHEN c.collisdeterministic THEN '%s' ELSE '%s' END AS \"%s\"",
gettext_noop("yes"), gettext_noop("no"),
gettext_noop("Deterministic?"));
else
appendPQExpBuffer(&buf,
- ",\n '%s' AS \"%s\"",
+ " '%s' AS \"%s\"",
gettext_noop("yes"),
gettext_noop("Deterministic?"));
if (verbose)
appendPQExpBuffer(&buf,
- ",\n pg_catalog.obj_description(c.oid, 'pg_collation') AS \"%s\"",
+ ",\n pg_catalog.obj_description(c.oid, 'pg_collation') AS \"%s\"",
gettext_noop("Description"));
appendPQExpBufferStr(&buf,