|
15 | 15 | #include <ctype.h>
|
16 | 16 |
|
17 | 17 | #include "catalog/pg_attribute_d.h"
|
| 18 | +#include "catalog/pg_cast_d.h" |
18 | 19 | #include "catalog/pg_class_d.h"
|
19 | 20 | #include "catalog/pg_default_acl_d.h"
|
20 | 21 | #include "fe_utils/string_utils.h"
|
@@ -3953,37 +3954,56 @@ listCasts(const char *pattern, bool verbose)
|
3953 | 3954 |
|
3954 | 3955 | initPQExpBuffer(&buf);
|
3955 | 3956 |
|
3956 |
| - /* |
3957 |
| - * We need a left join to pg_proc for binary casts; the others are just |
3958 |
| - * paranoia. Also note that we don't attempt to localize '(binary |
3959 |
| - * coercible)', because there's too much risk of gettext translating a |
3960 |
| - * function name that happens to match some string in the PO database. |
3961 |
| - */ |
3962 | 3957 | printfPQExpBuffer(&buf,
|
3963 | 3958 | "SELECT pg_catalog.format_type(castsource, NULL) AS \"%s\",\n"
|
3964 |
| - " pg_catalog.format_type(casttarget, NULL) AS \"%s\",\n" |
3965 |
| - " CASE WHEN castfunc = 0 THEN '(binary coercible)'\n" |
3966 |
| - " ELSE p.proname\n" |
3967 |
| - " END as \"%s\",\n" |
3968 |
| - " CASE WHEN c.castcontext = 'e' THEN '%s'\n" |
3969 |
| - " WHEN c.castcontext = 'a' THEN '%s'\n" |
3970 |
| - " ELSE '%s'\n" |
3971 |
| - " END as \"%s\"", |
| 3959 | + " pg_catalog.format_type(casttarget, NULL) AS \"%s\",\n", |
3972 | 3960 | gettext_noop("Source type"),
|
3973 |
| - gettext_noop("Target type"), |
3974 |
| - gettext_noop("Function"), |
| 3961 | + gettext_noop("Target type")); |
| 3962 | + |
| 3963 | + /* |
| 3964 | + * We don't attempt to localize '(binary coercible)' or '(with inout)', |
| 3965 | + * because there's too much risk of gettext translating a function name |
| 3966 | + * that happens to match some string in the PO database. |
| 3967 | + */ |
| 3968 | + if (pset.sversion >= 80400) |
| 3969 | + appendPQExpBuffer(&buf, |
| 3970 | + " CASE WHEN c.castmethod = '%c' THEN '(binary coercible)'\n" |
| 3971 | + " WHEN c.castmethod = '%c' THEN '(with inout)'\n" |
| 3972 | + " ELSE p.proname\n" |
| 3973 | + " END AS \"%s\",\n", |
| 3974 | + COERCION_METHOD_BINARY, |
| 3975 | + COERCION_METHOD_INOUT, |
| 3976 | + gettext_noop("Function")); |
| 3977 | + else |
| 3978 | + appendPQExpBuffer(&buf, |
| 3979 | + " CASE WHEN c.castfunc = 0 THEN '(binary coercible)'\n" |
| 3980 | + " ELSE p.proname\n" |
| 3981 | + " END AS \"%s\",\n", |
| 3982 | + gettext_noop("Function")); |
| 3983 | + |
| 3984 | + appendPQExpBuffer(&buf, |
| 3985 | + " CASE WHEN c.castcontext = '%c' THEN '%s'\n" |
| 3986 | + " WHEN c.castcontext = '%c' THEN '%s'\n" |
| 3987 | + " ELSE '%s'\n" |
| 3988 | + " END AS \"%s\"", |
| 3989 | + COERCION_CODE_EXPLICIT, |
3975 | 3990 | gettext_noop("no"),
|
| 3991 | + COERCION_CODE_ASSIGNMENT, |
3976 | 3992 | gettext_noop("in assignment"),
|
3977 | 3993 | gettext_noop("yes"),
|
3978 | 3994 | gettext_noop("Implicit?"));
|
3979 | 3995 |
|
3980 | 3996 | if (verbose)
|
3981 | 3997 | appendPQExpBuffer(&buf,
|
3982 |
| - ",\n d.description AS \"%s\"\n", |
| 3998 | + ",\n d.description AS \"%s\"", |
3983 | 3999 | gettext_noop("Description"));
|
3984 | 4000 |
|
| 4001 | + /* |
| 4002 | + * We need a left join to pg_proc for binary casts; the others are just |
| 4003 | + * paranoia. |
| 4004 | + */ |
3985 | 4005 | appendPQExpBufferStr(&buf,
|
3986 |
| - "FROM pg_catalog.pg_cast c LEFT JOIN pg_catalog.pg_proc p\n" |
| 4006 | + "\nFROM pg_catalog.pg_cast c LEFT JOIN pg_catalog.pg_proc p\n" |
3987 | 4007 | " ON c.castfunc = p.oid\n"
|
3988 | 4008 | " LEFT JOIN pg_catalog.pg_type ts\n"
|
3989 | 4009 | " ON c.castsource = ts.oid\n"
|
|
0 commit comments