8
8
*
9
9
* Copyright (c) 2000-2008, PostgreSQL Global Development Group
10
10
*
11
- * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.186 2008/11/03 19:08:56 tgl Exp $
11
+ * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.187 2008/11/06 15:18:35 tgl Exp $
12
12
*/
13
13
#include "postgres_fe.h"
14
14
@@ -2082,10 +2082,10 @@ listCasts(const char *pattern)
2082
2082
2083
2083
initPQExpBuffer (& buf );
2084
2084
/*
2085
- * We need left join here for binary casts. Also note that we don't
2086
- * attempt to localize '(binary coercible)', because there's too much
2087
- * risk of gettext translating a function name that happens to match
2088
- * some string in the PO database.
2085
+ * We need a left join to pg_proc for binary casts; the others are just
2086
+ * paranoia. Also note that we don't attempt to localize '(binary
2087
+ * coercible)', because there's too much risk of gettext translating a
2088
+ * function name that happens to match some string in the PO database.
2089
2089
*/
2090
2090
printfPQExpBuffer (& buf ,
2091
2091
"SELECT pg_catalog.format_type(castsource, NULL) AS \"%s\",\n"
@@ -2099,13 +2099,39 @@ listCasts(const char *pattern)
2099
2099
" END as \"%s\"\n"
2100
2100
"FROM pg_catalog.pg_cast c LEFT JOIN pg_catalog.pg_proc p\n"
2101
2101
" ON c.castfunc = p.oid\n"
2102
- "ORDER BY 1, 2" ,
2102
+ " LEFT JOIN pg_catalog.pg_type ts\n"
2103
+ " ON c.castsource = ts.oid\n"
2104
+ " LEFT JOIN pg_catalog.pg_namespace ns\n"
2105
+ " ON ns.oid = ts.typnamespace\n"
2106
+ " LEFT JOIN pg_catalog.pg_type tt\n"
2107
+ " ON c.casttarget = tt.oid\n"
2108
+ " LEFT JOIN pg_catalog.pg_namespace nt\n"
2109
+ " ON nt.oid = tt.typnamespace\n"
2110
+ "WHERE (true" ,
2103
2111
gettext_noop ("Source type" ),
2104
2112
gettext_noop ("Target type" ),
2105
2113
gettext_noop ("Function" ),
2106
2114
gettext_noop ("no" ), gettext_noop ("in assignment" ), gettext_noop ("yes" ),
2107
2115
gettext_noop ("Implicit?" ));
2108
2116
2117
+ /*
2118
+ * Match name pattern against either internal or external name of either
2119
+ * castsource or casttarget
2120
+ */
2121
+ processSQLNamePattern (pset .db , & buf , pattern , true, false,
2122
+ "ns.nspname" , "ts.typname" ,
2123
+ "pg_catalog.format_type(ts.oid, NULL)" ,
2124
+ "pg_catalog.pg_type_is_visible(ts.oid)" );
2125
+
2126
+ appendPQExpBuffer (& buf , ") OR (true" );
2127
+
2128
+ processSQLNamePattern (pset .db , & buf , pattern , true, false,
2129
+ "nt.nspname" , "tt.typname" ,
2130
+ "pg_catalog.format_type(tt.oid, NULL)" ,
2131
+ "pg_catalog.pg_type_is_visible(tt.oid)" );
2132
+
2133
+ appendPQExpBuffer (& buf , ")\nORDER BY 1, 2;" );
2134
+
2109
2135
res = PSQLexec (buf .data , false);
2110
2136
termPQExpBuffer (& buf );
2111
2137
if (!res )
0 commit comments