Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p2LRg-0005jm-4n for pgsql-hackers@arkaria.postgresql.org; Tue, 06 Dec 2022 00:04:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1p2LRe-0000Yz-V8 for pgsql-hackers@arkaria.postgresql.org; Tue, 06 Dec 2022 00:04:22 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p2LRe-0000Yq-IQ for pgsql-hackers@lists.postgresql.org; Tue, 06 Dec 2022 00:04:22 +0000 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1p2LRb-0000RQ-RQ for pgsql-hackers@postgresql.org; Tue, 06 Dec 2022 00:04:22 +0000 Received: by mail-pl1-x632.google.com with SMTP id d3so12357652plr.10 for ; Mon, 05 Dec 2022 16:04:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=dAs423Cxd/k1lROdn9e1/GNexVgwxYcvR/XtKgHL02w=; b=R0FzKPFyACH7y9vZNKswHvb/U7Voynz+vwtfPCkLTKll0eBudbU3/MbduuKtjTvKSs 1wkC/KtvL+6UKnRu9fvjuB6aQ8TrsdXCmM/uIULldU9Hwj0DrbSOjNhESLnMl2fcvhpY madiPfaYOdXSeb+CWeFus+8gQ0oLOeR1f+l68jkjDdoQMXfJb7iRR1fv67ealJGgLIE3 /ucU/rY2AVWa669kXonxTeqckCSDvKjtKg/ew+qTpbdBsRPfSZ6gW7HYDph+R1MIMBst lw/+HZNlSB/DmFqc4TdI0k68YB9DvKiqaduwMrRoNtxPFaK6zBz15KW1+SYQklt0n6ES VcHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=dAs423Cxd/k1lROdn9e1/GNexVgwxYcvR/XtKgHL02w=; b=KHTlJYdhjGlMXjv3AIDpD05u82Ob0fAZpdR+3VGx3oQIeVPj3LyHwlNC06pHX9bz/r ebxYF6H04hAHys1oIyItUqyZh93Hf/vEhiUPT19m3jMBmHicxKJCdoFNVZr4cXkKZOPR PHItTk/rMu9oF+Anbl9iZXyXqvfWsW4RieVB2BQPdVNXO8qHpO7+0C0akE1r+x0kYbQx jHiLUs2oOLE4h5mvOWFEeRj52NgeKXNWxLYGcwCSBx5hAHD005u5QphUBvT+QNoKf/hc 8sniIejHngpglGNSlbOZk6yinZFipWuMQj3XMhPRTe0a1sxqjBIyLkLqDmWzu6MKUDHH 4GEw== X-Gm-Message-State: ANoB5pnol85EbTTf1Mk9fcL9c8eQO4B1qCkQ5Gb5DgLh5ai2v4sA3d9g a81wBSn/fqS8iug2pulhChY= X-Google-Smtp-Source: AA0mqf7hQklJMr8trtHB/etXqxSNozOOWWBa6O8etHPU3K19uXDuS9gTkc+75abOUVeLrB5HEt4D1A== X-Received: by 2002:a17:90a:f0cf:b0:219:f383:ecb0 with SMTP id fa15-20020a17090af0cf00b00219f383ecb0mr2086963pjb.224.1670285057526; Mon, 05 Dec 2022 16:04:17 -0800 (PST) Received: from nathanxps13 ([50.47.162.83]) by smtp.gmail.com with ESMTPSA id q13-20020a17090311cd00b00189929219acsm11190922plh.183.2022.12.05.16.04.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Dec 2022 16:04:16 -0800 (PST) Date: Mon, 5 Dec 2022 16:04:14 -0800 From: Nathan Bossart To: Pavel Luzanov Cc: Andrew Dunstan , Corey Huinker , Tom Lane , Stephen Frost , Bharath Rupireddy , "David G. Johnston" , Kyotaro Horiguchi , Michael Paquier , Robert Haas , "pgsql-hackers@postgresql.org" Subject: Re: predefined role(s) for VACUUM and ANALYZE Message-ID: <20221206000414.GA2813564@nathanxps13> References: <20221115050813.GA1953731@nathanxps13> <287b17b8-92f3-2bc2-6bcf-31dc1305b65a@dunslane.net> <20221117043952.GA116054@nathanxps13> <20221118170504.GA401589@nathanxps13> <20221119185004.GA539143@nathanxps13> <20221120165713.GA597801@nathanxps13> <0b00a6ff-1475-c0ba-15ec-5b5e381c6359@dunslane.net> <20221123235444.GA479104@nathanxps13> <8609e4f7-5ffd-9fef-a5e0-78edb8818f3c@dunslane.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="OXfL5xGRrasGEqWY" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --OXfL5xGRrasGEqWY Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Dec 05, 2022 at 11:21:08PM +0300, Pavel Luzanov wrote: > But perhaps this behavior should be reviewed or at least documented? I wonder why \dpS wasn't added. I wrote up a patch to add it and the corresponding documentation that other meta-commands already have. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com --OXfL5xGRrasGEqWY Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="add_s_modifier_to_dp.patch" diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index d3dd638b14..406936dd1c 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -1825,14 +1825,16 @@ INSERT INTO tbl1 VALUES ($1, $2) \bind 'first value' 'second value' \g - \dp [ pattern ] + \dp[S] [ pattern ] Lists tables, views and sequences with their associated access privileges. If pattern is specified, only tables, views and sequences whose names match the - pattern are listed. + pattern are listed. By default only user-created objects are shown; + supply a pattern or the S modifier to include system + objects. diff --git a/src/bin/psql/command.c b/src/bin/psql/command.c index de6a3a71f8..3520655dc0 100644 --- a/src/bin/psql/command.c +++ b/src/bin/psql/command.c @@ -875,7 +875,7 @@ exec_command_d(PsqlScanState scan_state, bool active_branch, const char *cmd) success = listCollations(pattern, show_verbose, show_system); break; case 'p': - success = permissionsList(pattern); + success = permissionsList(pattern, show_system); break; case 'P': { @@ -2831,7 +2831,7 @@ exec_command_z(PsqlScanState scan_state, bool active_branch) char *pattern = psql_scan_slash_option(scan_state, OT_NORMAL, NULL, true); - success = permissionsList(pattern); + success = permissionsList(pattern, false); free(pattern); } else diff --git a/src/bin/psql/describe.c b/src/bin/psql/describe.c index 2eae519b1d..eb98797d67 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,12 @@ 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_'\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; diff --git a/src/bin/psql/describe.h b/src/bin/psql/describe.h index bd051e09cb..58d0cf032b 100644 --- a/src/bin/psql/describe.h +++ b/src/bin/psql/describe.h @@ -38,7 +38,7 @@ extern bool describeRoles(const char *pattern, bool verbose, bool showSystem); extern bool listDbRoleSettings(const char *pattern, const char *pattern2); /* \z (or \dp) */ -extern bool permissionsList(const char *pattern); +extern bool permissionsList(const char *pattern, bool showSystem); /* \ddp */ extern bool listDefaultACLs(const char *pattern); --OXfL5xGRrasGEqWY--