aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2018-08-31 16:45:33 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2018-08-31 16:45:33 -0400
commited9c336b0f6bcf08e7b6bbe7080fdb63640a680e (patch)
tree4ef4c322656c9315549792b8aa0124d39a7c2b7c /src
parentc34f8078aa354a9c352b6db488ca1d5aac39560c (diff)
downloadpostgresql-ed9c336b0f6bcf08e7b6bbe7080fdb63640a680e.tar.gz
postgresql-ed9c336b0f6bcf08e7b6bbe7080fdb63640a680e.zip
Fix psql's \dC command to annotate I/O conversion casts as such.
A cast declared WITH INOUT was described as '(binary coercible)', which seems pretty inaccurate; let's print '(with inout)' instead. Per complaint from Jean-Pierre Pelletier. This definitely seems like a bug fix, but given that it's been wrong since 8.4 and nobody complained before, I'm hesitant to back-patch a behavior change into stable branches. It doesn't seem too late for v11 though. Discussion: https://postgr.es/m/5b887023.1c69fb81.ff96e.6a1d@mx.google.com
Diffstat (limited to 'src')
-rw-r--r--src/bin/psql/describe.c56
1 files changed, 38 insertions, 18 deletions
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 4f7e93fe024..4ca0db1d0ca 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -15,6 +15,7 @@
#include <ctype.h>
#include "catalog/pg_attribute_d.h"
+#include "catalog/pg_cast_d.h"
#include "catalog/pg_class_d.h"
#include "catalog/pg_default_acl_d.h"
#include "fe_utils/string_utils.h"
@@ -3953,37 +3954,56 @@ listCasts(const char *pattern, bool verbose)
initPQExpBuffer(&buf);
- /*
- * We need a left join to pg_proc for binary casts; the others are just
- * paranoia. Also note that we don't attempt to localize '(binary
- * coercible)', because there's too much risk of gettext translating a
- * function name that happens to match some string in the PO database.
- */
printfPQExpBuffer(&buf,
"SELECT pg_catalog.format_type(castsource, NULL) AS \"%s\",\n"
- " pg_catalog.format_type(casttarget, NULL) AS \"%s\",\n"
- " CASE WHEN castfunc = 0 THEN '(binary coercible)'\n"
- " ELSE p.proname\n"
- " END as \"%s\",\n"
- " CASE WHEN c.castcontext = 'e' THEN '%s'\n"
- " WHEN c.castcontext = 'a' THEN '%s'\n"
- " ELSE '%s'\n"
- " END as \"%s\"",
+ " pg_catalog.format_type(casttarget, NULL) AS \"%s\",\n",
gettext_noop("Source type"),
- gettext_noop("Target type"),
- gettext_noop("Function"),
+ gettext_noop("Target type"));
+
+ /*
+ * We don't attempt to localize '(binary coercible)' or '(with inout)',
+ * because there's too much risk of gettext translating a function name
+ * that happens to match some string in the PO database.
+ */
+ if (pset.sversion >= 80400)
+ appendPQExpBuffer(&buf,
+ " CASE WHEN c.castmethod = '%c' THEN '(binary coercible)'\n"
+ " WHEN c.castmethod = '%c' THEN '(with inout)'\n"
+ " ELSE p.proname\n"
+ " END AS \"%s\",\n",
+ COERCION_METHOD_BINARY,
+ COERCION_METHOD_INOUT,
+ gettext_noop("Function"));
+ else
+ appendPQExpBuffer(&buf,
+ " CASE WHEN c.castfunc = 0 THEN '(binary coercible)'\n"
+ " ELSE p.proname\n"
+ " END AS \"%s\",\n",
+ gettext_noop("Function"));
+
+ appendPQExpBuffer(&buf,
+ " CASE WHEN c.castcontext = '%c' THEN '%s'\n"
+ " WHEN c.castcontext = '%c' THEN '%s'\n"
+ " ELSE '%s'\n"
+ " END AS \"%s\"",
+ COERCION_CODE_EXPLICIT,
gettext_noop("no"),
+ COERCION_CODE_ASSIGNMENT,
gettext_noop("in assignment"),
gettext_noop("yes"),
gettext_noop("Implicit?"));
if (verbose)
appendPQExpBuffer(&buf,
- ",\n d.description AS \"%s\"\n",
+ ",\n d.description AS \"%s\"",
gettext_noop("Description"));
+ /*
+ * We need a left join to pg_proc for binary casts; the others are just
+ * paranoia.
+ */
appendPQExpBufferStr(&buf,
- "FROM pg_catalog.pg_cast c LEFT JOIN pg_catalog.pg_proc p\n"
+ "\nFROM pg_catalog.pg_cast c LEFT JOIN pg_catalog.pg_proc p\n"
" ON c.castfunc = p.oid\n"
" LEFT JOIN pg_catalog.pg_type ts\n"
" ON c.castsource = ts.oid\n"