88 *
99 * Copyright (c) 2000-2008, PostgreSQL Global Development Group
1010 *
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 $
1212 */
1313#include "postgres_fe.h"
1414
@@ -2082,10 +2082,10 @@ listCasts(const char *pattern)
20822082
20832083initPQExpBuffer (& buf );
20842084/*
2085- * We need left joinhere 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 needa left jointo 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.
20892089 */
20902090printfPQExpBuffer (& buf ,
20912091"SELECT pg_catalog.format_type(castsource, NULL) AS \"%s\",\n"
@@ -2099,13 +2099,39 @@ listCasts(const char *pattern)
20992099" END as \"%s\"\n"
21002100"FROM pg_catalog.pg_cast c LEFT JOIN pg_catalog.pg_proc p\n"
21012101" 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" ,
21032111gettext_noop ("Source type" ),
21042112gettext_noop ("Target type" ),
21052113gettext_noop ("Function" ),
21062114gettext_noop ("no" ),gettext_noop ("in assignment" ),gettext_noop ("yes" ),
21072115gettext_noop ("Implicit?" ));
21082116
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+
21092135res = PSQLexec (buf .data , false);
21102136termPQExpBuffer (& buf );
21112137if (!res )