mirror of
https://github.com/postgres/postgres.git
synced 2025-07-05 07:21:24 +03:00
Implement an "S" option for psql's \dn command.
\dn without "S" now hides all pg_XXX schemas as well as information_schema. Thus, in a bare database you'll only see "public". ("public" is considered a user schema, not a system schema, mainly because it's droppable.) Per discussion back in late September.
This commit is contained in:
@ -1232,16 +1232,17 @@ testdb=>
|
|||||||
|
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><literal>\dn[+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
|
<term><literal>\dn[S+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
|
||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Lists schemas (namespaces). If <replaceable
|
Lists schemas (namespaces). If <replaceable
|
||||||
class="parameter">pattern</replaceable>
|
class="parameter">pattern</replaceable>
|
||||||
is specified, only schemas whose names match the pattern are listed.
|
is specified, only schemas whose names match the pattern are listed.
|
||||||
Non-local temporary schemas are suppressed. If <literal>+</literal>
|
By default, only user-created objects are shown; supply a
|
||||||
is appended to the command name, each object is listed with its associated
|
pattern or the <literal>S</literal> modifier to include system objects.
|
||||||
permissions and description, if any.
|
If <literal>+</literal> is appended to the command name, each object
|
||||||
|
is listed with its associated permissions and description, if any.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
@ -417,7 +417,7 @@ exec_command(const char *cmd,
|
|||||||
success = do_lo_list();
|
success = do_lo_list();
|
||||||
break;
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
success = listSchemas(pattern, show_verbose);
|
success = listSchemas(pattern, show_verbose, show_system);
|
||||||
break;
|
break;
|
||||||
case 'o':
|
case 'o':
|
||||||
success = describeOperators(pattern, show_system);
|
success = describeOperators(pattern, show_system);
|
||||||
|
@ -2697,7 +2697,7 @@ listCasts(const char *pattern)
|
|||||||
* Describes schemas (namespaces)
|
* Describes schemas (namespaces)
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
listSchemas(const char *pattern, bool verbose)
|
listSchemas(const char *pattern, bool verbose, bool showSystem)
|
||||||
{
|
{
|
||||||
PQExpBufferData buf;
|
PQExpBufferData buf;
|
||||||
PGresult *res;
|
PGresult *res;
|
||||||
@ -2720,11 +2720,14 @@ listSchemas(const char *pattern, bool verbose)
|
|||||||
}
|
}
|
||||||
|
|
||||||
appendPQExpBuffer(&buf,
|
appendPQExpBuffer(&buf,
|
||||||
"\nFROM pg_catalog.pg_namespace n\n"
|
"\nFROM pg_catalog.pg_namespace n\n");
|
||||||
"WHERE (n.nspname !~ '^pg_temp_' OR\n"
|
|
||||||
" n.nspname = (pg_catalog.current_schemas(true))[1])\n"); /* temp schema is first */
|
|
||||||
|
|
||||||
processSQLNamePattern(pset.db, &buf, pattern, true, false,
|
if (!showSystem && !pattern)
|
||||||
|
appendPQExpBuffer(&buf,
|
||||||
|
"WHERE n.nspname !~ '^pg_' AND n.nspname <> 'information_schema'\n");
|
||||||
|
|
||||||
|
processSQLNamePattern(pset.db, &buf, pattern,
|
||||||
|
!showSystem && !pattern, false,
|
||||||
NULL, "n.nspname", NULL,
|
NULL, "n.nspname", NULL,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ extern bool listConversions(const char *pattern, bool showSystem);
|
|||||||
extern bool listCasts(const char *pattern);
|
extern bool listCasts(const char *pattern);
|
||||||
|
|
||||||
/* \dn */
|
/* \dn */
|
||||||
extern bool listSchemas(const char *pattern, bool verbose);
|
extern bool listSchemas(const char *pattern, bool verbose, bool showSystem);
|
||||||
|
|
||||||
/* \dew */
|
/* \dew */
|
||||||
extern bool listForeignDataWrappers(const char *pattern, bool verbose);
|
extern bool listForeignDataWrappers(const char *pattern, bool verbose);
|
||||||
|
Reference in New Issue
Block a user