aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2011-04-09 14:08:41 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2011-04-09 14:08:41 -0400
commit7c76906b7e24d9ea94a2b0e33396ebcac600437d (patch)
treef7f47e8e007baa63549aaded224c6d766834619b /src
parentfe1438da8aa8a45f2cee816eb54841f97d3b2f22 (diff)
downloadpostgresql-7c76906b7e24d9ea94a2b0e33396ebcac600437d.tar.gz
postgresql-7c76906b7e24d9ea94a2b0e33396ebcac600437d.zip
Don't show unusable collations in psql's \dO command.
"Unusable" collations are those not matching the current database's encoding. The former behavior inconsistently showed such collations some of the time, depending on the details of the pattern argument.
Diffstat (limited to 'src')
-rw-r--r--src/bin/psql/describe.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 09a40093d1f..a30eaeb10f6 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -2883,7 +2883,7 @@ listCasts(const char *pattern)
/*
* \dO
*
- * Describes collations
+ * Describes collations.
*/
bool
listCollations(const char *pattern, bool verbose, bool showSystem)
@@ -2907,17 +2907,25 @@ listCollations(const char *pattern, bool verbose, bool showSystem)
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"));
appendPQExpBuffer(&buf,
- "FROM pg_catalog.pg_collation c, pg_catalog.pg_namespace n\n"
+ "\nFROM pg_catalog.pg_collation c, pg_catalog.pg_namespace n\n"
"WHERE n.oid = c.collnamespace\n");
if (!showSystem && !pattern)
appendPQExpBuffer(&buf, " AND n.nspname <> 'pg_catalog'\n"
" AND n.nspname <> 'information_schema'\n");
+ /*
+ * Hide collations that aren't usable in the current database's encoding.
+ * If you think to change this, note that pg_collation_is_visible rejects
+ * unusable collations, so you will need to hack name pattern processing
+ * somehow to avoid inconsistent behavior.
+ */
+ appendPQExpBuffer(&buf, " AND c.collencoding IN (-1, pg_catalog.pg_char_to_encoding(pg_catalog.getdatabaseencoding()))\n");
+
processSQLNamePattern(pset.db, &buf, pattern, true, false,
"n.nspname", "c.collname", NULL,
"pg_catalog.pg_collation_is_visible(c.oid)");