Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite43fb60

Browse files
committed
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 considereda user schema, not a system schema, mainly because it's droppable.)Per discussion back in late September.
1 parentd7a2ce4 commite43fb60

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

‎doc/src/sgml/ref/psql-ref.sgml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,16 +1232,17 @@ testdb=>
12321232

12331233

12341234
<varlistentry>
1235-
<term><literal>\dn[+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
1235+
<term><literal>\dn[S+] [ <link linkend="APP-PSQL-patterns"><replaceable class="parameter">pattern</replaceable></link> ]</literal></term>
12361236

12371237
<listitem>
12381238
<para>
12391239
Lists schemas (namespaces). If <replaceable
12401240
class="parameter">pattern</replaceable>
12411241
is specified, only schemas whose names match the pattern are listed.
1242-
Non-local temporary schemas are suppressed. If <literal>+</literal>
1243-
is appended to the command name, each object is listed with its associated
1244-
permissions and description, if any.
1242+
By default, only user-created objects are shown; supply a
1243+
pattern or the <literal>S</literal> modifier to include system objects.
1244+
If <literal>+</literal> is appended to the command name, each object
1245+
is listed with its associated permissions and description, if any.
12451246
</para>
12461247
</listitem>
12471248
</varlistentry>

‎src/bin/psql/command.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ exec_command(const char *cmd,
417417
success=do_lo_list();
418418
break;
419419
case'n':
420-
success=listSchemas(pattern,show_verbose);
420+
success=listSchemas(pattern,show_verbose,show_system);
421421
break;
422422
case'o':
423423
success=describeOperators(pattern,show_system);

‎src/bin/psql/describe.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2697,7 +2697,7 @@ listCasts(const char *pattern)
26972697
* Describes schemas (namespaces)
26982698
*/
26992699
bool
2700-
listSchemas(constchar*pattern,boolverbose)
2700+
listSchemas(constchar*pattern,boolverbose,boolshowSystem)
27012701
{
27022702
PQExpBufferDatabuf;
27032703
PGresult*res;
@@ -2720,11 +2720,14 @@ listSchemas(const char *pattern, bool verbose)
27202720
}
27212721

27222722
appendPQExpBuffer(&buf,
2723-
"\nFROM pg_catalog.pg_namespace n\n"
2724-
"WHERE(n.nspname !~ '^pg_temp_' OR\n"
2725-
" n.nspname = (pg_catalog.current_schemas(true))[1])\n");/* temp schema is first */
2723+
"\nFROM pg_catalog.pg_namespace n\n");
27262724

2727-
processSQLNamePattern(pset.db,&buf,pattern, true, false,
2725+
if (!showSystem&& !pattern)
2726+
appendPQExpBuffer(&buf,
2727+
"WHERE n.nspname !~ '^pg_' AND n.nspname <> 'information_schema'\n");
2728+
2729+
processSQLNamePattern(pset.db,&buf,pattern,
2730+
!showSystem&& !pattern, false,
27282731
NULL,"n.nspname",NULL,
27292732
NULL);
27302733

‎src/bin/psql/describe.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ extern bool listConversions(const char *pattern, bool showSystem);
7070
externboollistCasts(constchar*pattern);
7171

7272
/* \dn */
73-
externboollistSchemas(constchar*pattern,boolverbose);
73+
externboollistSchemas(constchar*pattern,boolverbose,boolshowSystem);
7474

7575
/* \dew */
7676
externboollistForeignDataWrappers(constchar*pattern,boolverbose);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp