Apply the proper version of Christopher Kings-Lynne's describe patch
(ie, the one with describe-schema support). Minor code review. Adjust display of casts to use standard type names.
This commit is contained in:
parent
1b59b442ce
commit
b4b62cff93
@ -1,5 +1,5 @@
|
||||
<!--
|
||||
$Header: /cvsroot/pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.83 2003/01/07 18:46:52 momjian Exp $
|
||||
$Header: /cvsroot/pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.84 2003/01/07 20:56:06 tgl Exp $
|
||||
PostgreSQL documentation
|
||||
-->
|
||||
|
||||
@ -798,6 +798,30 @@ testdb=>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
||||
<varlistentry>
|
||||
<term><literal>\dc</literal> [ <replaceable class="parameter">pattern</replaceable> ]</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Lists all available conversions between character-set encodings.
|
||||
If <replaceable class="parameter">pattern</replaceable>
|
||||
is specified, only conversions whose name matches the pattern are
|
||||
listed.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
||||
<varlistentry>
|
||||
<term><literal>\dC</literal></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Lists all available type casts.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
||||
<varlistentry>
|
||||
<term><literal>\dd</literal> [ <replaceable class="parameter">pattern</replaceable> ]</term>
|
||||
<listitem>
|
||||
@ -847,29 +871,6 @@ testdb=>
|
||||
</varlistentry>
|
||||
|
||||
|
||||
<varlistentry>
|
||||
<term><literal>\dc</literal> [ <replaceable class="parameter">pattern</replaceable> ]</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Lists all available conversions (between encodings). If <replaceable
|
||||
class="parameter">pattern</replaceable>
|
||||
is specified, only matching conversions are shown.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
||||
<varlistentry>
|
||||
<term><literal>\dC</literal></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Lists all available type casts. Casts can be explicit, explicit and assignment
|
||||
or implicit, and are used to change a variable from one type to another.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
||||
<varlistentry>
|
||||
<term><literal>\df [ <replaceable class="parameter">pattern</replaceable> ]</literal></term>
|
||||
|
||||
@ -929,6 +930,19 @@ testdb=>
|
||||
</varlistentry>
|
||||
|
||||
|
||||
<varlistentry>
|
||||
<term><literal>\dn</literal> [ <replaceable class="parameter">pattern</replaceable> ]</term>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
Lists all available schemas (namespaces). If <replaceable
|
||||
class="parameter">pattern</replaceable> (a regular expression)
|
||||
is specified, only schemas whose name matches the pattern are listed.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
||||
<varlistentry>
|
||||
<term><literal>\do [ <replaceable class="parameter">pattern</replaceable> ]</literal></term>
|
||||
<listitem>
|
||||
@ -1054,8 +1068,9 @@ Tue Oct 26 21:40:57 CEST 1999
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
This command does not see changes made by <command>SET
|
||||
CLIENT_ENCODING</>.
|
||||
This command will not notice changes made directly by <command>SET
|
||||
CLIENT_ENCODING</>. If you use <literal>\encoding</literal>,
|
||||
be sure to use it to set as well as examine the encoding.
|
||||
</para>
|
||||
</note>
|
||||
</listitem>
|
||||
|
@ -13,7 +13,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/namespace.c,v 1.42 2002/12/12 21:02:19 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/namespace.c,v 1.43 2003/01/07 20:56:06 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -145,6 +145,7 @@ Datum pg_operator_is_visible(PG_FUNCTION_ARGS);
|
||||
Datum pg_opclass_is_visible(PG_FUNCTION_ARGS);
|
||||
Datum pg_conversion_is_visible(PG_FUNCTION_ARGS);
|
||||
|
||||
|
||||
/*
|
||||
* RangeVarGetRelid
|
||||
* Given a RangeVar describing an existing relation,
|
||||
@ -1084,7 +1085,7 @@ ConversionIsVisible(Oid conid)
|
||||
ObjectIdGetDatum(conid),
|
||||
0, 0, 0);
|
||||
if (!HeapTupleIsValid(contup))
|
||||
elog(ERROR, "Cache lookup failed for converions %u", conid);
|
||||
elog(ERROR, "Cache lookup failed for conversion %u", conid);
|
||||
conform = (Form_pg_conversion) GETSTRUCT(contup);
|
||||
|
||||
recomputeNamespacePath();
|
||||
@ -1104,7 +1105,7 @@ ConversionIsVisible(Oid conid)
|
||||
* If it is in the path, it might still not be visible; it could
|
||||
* be hidden by another conversion of the same name earlier in the
|
||||
* path. So we must do a slow check to see if this conversion would
|
||||
* be found by ConvnameGetConid.
|
||||
* be found by ConversionGetConid.
|
||||
*/
|
||||
char *conname = NameStr(conform->conname);
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
*
|
||||
* Copyright 2000-2002 by PostgreSQL Global Development Group
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.86 2002/12/12 21:02:21 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.87 2003/01/07 20:56:06 tgl Exp $
|
||||
*/
|
||||
#include "postgres_fe.h"
|
||||
#include "command.h"
|
||||
@ -350,15 +350,27 @@ exec_command(const char *cmd,
|
||||
case 'a':
|
||||
success = describeAggregates(pattern, show_verbose);
|
||||
break;
|
||||
case 'c':
|
||||
success = listConversions(pattern);
|
||||
break;
|
||||
case 'C':
|
||||
success = listCasts(pattern);
|
||||
break;
|
||||
case 'd':
|
||||
success = objectDescription(pattern);
|
||||
break;
|
||||
case 'D':
|
||||
success = listDomains(pattern);
|
||||
break;
|
||||
case 'f':
|
||||
success = describeFunctions(pattern, show_verbose);
|
||||
break;
|
||||
case 'l':
|
||||
success = do_lo_list();
|
||||
break;
|
||||
case 'n':
|
||||
success = listSchemas(pattern);
|
||||
break;
|
||||
case 'o':
|
||||
success = describeOperators(pattern);
|
||||
break;
|
||||
@ -378,16 +390,7 @@ exec_command(const char *cmd,
|
||||
case 'u':
|
||||
success = describeUsers(pattern);
|
||||
break;
|
||||
case 'D':
|
||||
success = listDomains(pattern);
|
||||
break;
|
||||
case 'c':
|
||||
success = listConversions(pattern);
|
||||
break;
|
||||
case 'C':
|
||||
success = listCasts(pattern);
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
status = CMD_UNKNOWN;
|
||||
}
|
||||
|
@ -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
|
||||
*
|
||||
|
@ -3,7 +3,7 @@
|
||||
*
|
||||
* Copyright 2000-2002 by PostgreSQL Global Development Group
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/bin/psql/describe.h,v 1.19 2002/12/12 21:02:24 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/bin/psql/describe.h,v 1.20 2003/01/07 20:56:07 tgl Exp $
|
||||
*/
|
||||
#ifndef DESCRIBE_H
|
||||
#define DESCRIBE_H
|
||||
@ -49,5 +49,8 @@ bool listConversions(const char *pattern);
|
||||
/* \dC */
|
||||
bool listCasts(const char *pattern);
|
||||
|
||||
/* \dn */
|
||||
bool listSchemas(const char *pattern);
|
||||
|
||||
|
||||
#endif /* DESCRIBE_H */
|
||||
|
@ -3,7 +3,7 @@
|
||||
*
|
||||
* Copyright 2000 by PostgreSQL Global Development Group
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/bin/psql/help.c,v 1.68 2002/12/13 22:17:57 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/bin/psql/help.c,v 1.69 2003/01/07 20:56:07 tgl Exp $
|
||||
*/
|
||||
#include "postgres_fe.h"
|
||||
#include "common.h"
|
||||
@ -211,6 +211,7 @@ slashUsage(unsigned short int pager)
|
||||
fprintf(output, _(" \\dd [PATTERN] show comment for object\n"));
|
||||
fprintf(output, _(" \\dD [PATTERN] list domains\n"));
|
||||
fprintf(output, _(" \\df [PATTERN] list functions (add \"+\" for more detail)\n"));
|
||||
fprintf(output, _(" \\dn [PATTERN] list schemas\n"));
|
||||
fprintf(output, _(" \\do [NAME] list operators\n"));
|
||||
fprintf(output, _(" \\dl list large objects, same as \\lo_list\n"));
|
||||
fprintf(output, _(" \\dp [PATTERN] list table access privileges\n"));
|
||||
|
@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $Id: namespace.h,v 1.23 2002/12/12 21:02:25 momjian Exp $
|
||||
* $Id: namespace.h,v 1.24 2003/01/07 20:56:07 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -65,8 +65,9 @@ extern bool OperatorIsVisible(Oid oprid);
|
||||
extern OpclassCandidateList OpclassGetCandidates(Oid amid);
|
||||
extern Oid OpclassnameGetOpcid(Oid amid, const char *opcname);
|
||||
extern bool OpclassIsVisible(Oid opcid);
|
||||
extern bool ConversionIsVisible(Oid opcid);
|
||||
|
||||
extern Oid ConversionGetConid(const char *conname);
|
||||
extern bool ConversionIsVisible(Oid conid);
|
||||
|
||||
extern void DeconstructQualifiedName(List *names,
|
||||
char **nspname_p,
|
||||
|
Loading…
x
Reference in New Issue
Block a user