|
|
|
@ -3,7 +3,7 @@ |
|
|
|
|
* |
|
|
|
|
* Copyright 2000-2002 by PostgreSQL Global Development Group |
|
|
|
|
* |
|
|
|
|
* $Header: /cvsroot/pgsql/src/bin/psql/describe.c,v 1.73 2002/12/21 01:07:07 tgl Exp $ |
|
|
|
|
* $Header: /cvsroot/pgsql/src/bin/psql/describe.c,v 1.74 2003/01/07 20:56:06 tgl Exp $ |
|
|
|
|
*/ |
|
|
|
|
#include "postgres_fe.h" |
|
|
|
|
#include "describe.h" |
|
|
|
@ -1426,15 +1426,16 @@ listConversions(const char *pattern) |
|
|
|
|
" pg_catalog.pg_encoding_to_char(c.conforencoding) AS \"%s\",\n" |
|
|
|
|
" pg_catalog.pg_encoding_to_char(c.contoencoding) AS \"%s\",\n" |
|
|
|
|
" CASE WHEN c.condefault THEN '%s'\n" |
|
|
|
|
" ELSE NULL END AS \"%s\"\n" |
|
|
|
|
" ELSE '%s' END AS \"%s\"\n" |
|
|
|
|
"FROM pg_catalog.pg_conversion c, pg_catalog.pg_namespace n\n" |
|
|
|
|
"WHERE n.oid = c.connamespace\n", |
|
|
|
|
_("Schema"), |
|
|
|
|
_("Name"), |
|
|
|
|
_("Source"), |
|
|
|
|
_("Dest"), |
|
|
|
|
_("default"), |
|
|
|
|
_("Modifier")); |
|
|
|
|
_("Destination"), |
|
|
|
|
_("yes"), |
|
|
|
|
_("no"), |
|
|
|
|
_("Default?")); |
|
|
|
|
|
|
|
|
|
processNamePattern(&buf, pattern, true, false, |
|
|
|
|
"n.nspname", "c.conname", NULL, |
|
|
|
@ -1471,9 +1472,9 @@ listCasts(const char *pattern) |
|
|
|
|
initPQExpBuffer(&buf); |
|
|
|
|
/* NEED LEFT JOIN FOR BINARY CASTS */ |
|
|
|
|
printfPQExpBuffer(&buf, |
|
|
|
|
"SELECT t1.typname AS \"%s\",\n" |
|
|
|
|
" t2.typname AS \"%s\",\n" |
|
|
|
|
" CASE WHEN p.proname IS NULL THEN '%s'\n" |
|
|
|
|
"SELECT pg_catalog.format_type(castsource, NULL) AS \"%s\",\n" |
|
|
|
|
" pg_catalog.format_type(casttarget, NULL) AS \"%s\",\n" |
|
|
|
|
" CASE WHEN castfunc = 0 THEN '%s'\n" |
|
|
|
|
" ELSE p.proname\n" |
|
|
|
|
" END as \"%s\",\n" |
|
|
|
|
" CASE WHEN c.castcontext = 'e' THEN '%s'\n" |
|
|
|
@ -1481,16 +1482,16 @@ listCasts(const char *pattern) |
|
|
|
|
" ELSE '%s'\n" |
|
|
|
|
" END as \"%s\"\n" |
|
|
|
|
"FROM pg_catalog.pg_cast c LEFT JOIN pg_catalog.pg_proc p\n" |
|
|
|
|
" ON c.castfunc=p.oid, pg_catalog.pg_type t1, pg_catalog.pg_type t2\n" |
|
|
|
|
"WHERE c.castsource=t1.oid AND c.casttarget=t2.oid ORDER BY 1, 2", |
|
|
|
|
" ON c.castfunc = p.oid\n" |
|
|
|
|
"ORDER BY 1, 2", |
|
|
|
|
_("Source"), |
|
|
|
|
_("Target"), |
|
|
|
|
_("BINARY"), |
|
|
|
|
_("Function"), |
|
|
|
|
_("explicit"), |
|
|
|
|
_("assignment explicit"), |
|
|
|
|
_("implicit"), |
|
|
|
|
_("Context")); |
|
|
|
|
_("no"), |
|
|
|
|
_("in assignment"), |
|
|
|
|
_("yes"), |
|
|
|
|
_("Implicit?")); |
|
|
|
|
|
|
|
|
|
res = PSQLexec(buf.data, false); |
|
|
|
|
termPQExpBuffer(&buf); |
|
|
|
@ -1506,6 +1507,48 @@ listCasts(const char *pattern) |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* \dn |
|
|
|
|
* |
|
|
|
|
* Describes schemas (namespaces) |
|
|
|
|
*/ |
|
|
|
|
bool |
|
|
|
|
listSchemas(const char *pattern) |
|
|
|
|
{ |
|
|
|
|
PQExpBufferData buf; |
|
|
|
|
PGresult *res; |
|
|
|
|
printQueryOpt myopt = pset.popt; |
|
|
|
|
|
|
|
|
|
initPQExpBuffer(&buf); |
|
|
|
|
printfPQExpBuffer(&buf, |
|
|
|
|
"SELECT n.nspname AS \"%s\",\n" |
|
|
|
|
" u.usename AS \"%s\"\n" |
|
|
|
|
"FROM pg_catalog.pg_namespace n LEFT JOIN pg_catalog.pg_user u\n" |
|
|
|
|
" ON n.nspowner=u.usesysid\n", |
|
|
|
|
_("Name"), |
|
|
|
|
_("Owner")); |
|
|
|
|
|
|
|
|
|
processNamePattern(&buf, pattern, false, false, |
|
|
|
|
NULL, "n.nspname", NULL, |
|
|
|
|
NULL); |
|
|
|
|
|
|
|
|
|
appendPQExpBuffer(&buf, "ORDER BY 1;"); |
|
|
|
|
|
|
|
|
|
res = PSQLexec(buf.data, false); |
|
|
|
|
termPQExpBuffer(&buf); |
|
|
|
|
if (!res) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
myopt.nullPrint = NULL; |
|
|
|
|
myopt.title = _("List of schemas"); |
|
|
|
|
|
|
|
|
|
printQuery(res, &myopt, pset.queryFout); |
|
|
|
|
|
|
|
|
|
PQclear(res); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* processNamePattern |
|
|
|
|
* |
|
|
|
|