aboutsummaryrefslogtreecommitdiff
path: root/src/bin/psql/describe.c
diff options
context:
space:
mode:
authorDean Rasheed <dean.a.rasheed@gmail.com>2023-01-07 11:09:26 +0000
committerDean Rasheed <dean.a.rasheed@gmail.com>2023-01-07 11:09:26 +0000
commitd913928c9c5e905d0062d1e7237b7fb5fbde61ed (patch)
tree1936179c312e92dd4c97854bfad1565bcb5b1b3e /src/bin/psql/describe.c
parent2b6df05461cb540d8f103dfe55f38efc09b4189b (diff)
downloadpostgresql-d913928c9c5e905d0062d1e7237b7fb5fbde61ed.tar.gz
postgresql-d913928c9c5e905d0062d1e7237b7fb5fbde61ed.zip
psql: Add support for \dpS and \zS.
This allows an optional "S" modifier to be added to \dp and \z, to have them include system objects in the list. Note that this also changes the behaviour of a bare \dp or \z without the "S" modifier to include temp objects in the list, and exclude information_schema objects, making them consistent with other psql meta-commands. Nathan Bossart, reviewed by Maxim Orlov. Discussion: https://postgr.es/m/20221206193606.GB3078082@nathanxps13
Diffstat (limited to 'src/bin/psql/describe.c')
-rw-r--r--src/bin/psql/describe.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c
index 523fab61b90..e280b6f76c2 100644
--- a/src/bin/psql/describe.c
+++ b/src/bin/psql/describe.c
@@ -1002,7 +1002,7 @@ listAllDbs(const char *pattern, bool verbose)
* \z (now also \dp -- perhaps more mnemonic)
*/
bool
-permissionsList(const char *pattern)
+permissionsList(const char *pattern, bool showSystem)
{
PQExpBufferData buf;
PGresult *res;
@@ -1121,15 +1121,13 @@ permissionsList(const char *pattern)
CppAsString2(RELKIND_FOREIGN_TABLE) ","
CppAsString2(RELKIND_PARTITIONED_TABLE) ")\n");
- /*
- * Unless a schema pattern is specified, we suppress system and temp
- * tables, since they normally aren't very interesting from a permissions
- * point of view. You can see 'em by explicit request though, eg with \z
- * pg_catalog.*
- */
+ if (!showSystem && !pattern)
+ appendPQExpBufferStr(&buf, " AND n.nspname <> 'pg_catalog'\n"
+ " AND n.nspname <> 'information_schema'\n");
+
if (!validateSQLNamePattern(&buf, pattern, true, false,
"n.nspname", "c.relname", NULL,
- "n.nspname !~ '^pg_' AND pg_catalog.pg_table_is_visible(c.oid)",
+ "pg_catalog.pg_table_is_visible(c.oid)",
NULL, 3))
goto error_return;