From: Jeff Davis <pgsql@j-davis.com>
To: Stephen Frost <sfrost@snowman.net>
To: Andres Freund <andres@anarazel.de>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Bossart, Nathan <bossartn@amazon.com>
Cc: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Subject: Re: Predefined role pg_maintenance for VACUUM, ANALYZE, CHECKPOINT.
Date: Mon, 08 Nov 2021 16:13:17 -0800
Message-ID: <c5d7045507b0ccac7d9421f52bf3b59b60e1150b.camel@j-davis.com> (raw)
In-Reply-To: <20211108174723.GI20998@tamriel.snowman.net>
References: <202110310026.zmhkxct6ka6c@alvherre.pgsql>
<6498F6FC-714B-4AC2-B0E1-9A5321654277@amazon.com>
<20211101165025.GS20998@tamriel.snowman.net>
<5e7a618de1b49ba1ceede54ee1b1d073bd57f1f4.camel@j-davis.com>
<20211104224204.ee5673h3qlzblh7e@alap3.anarazel.de>
<ae70a6ff7700a821849be0da6cd0da69e0e4b05e.camel@j-davis.com>
<CA+Tgmob9TxDV3X4+=eG9E+o80MW_qoJjTvvHhRt252OO=X9FbA@mail.gmail.com>
<20211107184649.mpncdezkzfq2v4pb@alap3.anarazel.de>
<20211108172318.GF20998@tamriel.snowman.net>
<20211108173325.6ury6xflvxq7yqbn@alap3.anarazel.de>
<20211108174723.GI20998@tamriel.snowman.net>
On Mon, 2021-11-08 at 12:47 -0500, Stephen Frost wrote:
>
> I don't feel as strongly as others apparently do on this point
> though,
> and I'd rather have non-superusers able to run CHECKPOINT *somehow*
> than not, so if the others feel like a predefined role is a better
> approach then I'm alright with that. Seems a bit overkill to me but
> it's also not like it's actually all that much code or work to do.
+1. It seems like the pg_checkpointer predefined role is the most
acceptable to everyone (even if not universally liked).
Attached a rebased version of that patch.
Regards,
Jeff Davis
Attachments:pg-checkpointer-role.diff (text/x-patch, 3.0K) downloaddiff --git a/doc/src/sgml/ref/checkpoint.sgml b/doc/src/sgml/ref/checkpoint.sgmlindex 2afee6d7b59..aebe8f8cd77 100644--- a/doc/src/sgml/ref/checkpoint.sgml+++ b/doc/src/sgml/ref/checkpoint.sgml@@ -52,7 +52,8 @@ CHECKPOINT
</para>
<para>
- Only superusers can call <command>CHECKPOINT</command>.+ Only superusers or members of the <literal>pg_checkpointer</literal> role+ can call <command>CHECKPOINT</command>.
</para>
</refsect1>
diff --git a/doc/src/sgml/user-manag.sgml b/doc/src/sgml/user-manag.sgmlindex afbf67c28cf..d5482cd5fc6 100644--- a/doc/src/sgml/user-manag.sgml+++ b/doc/src/sgml/user-manag.sgml@@ -582,6 +582,10 @@ DROP ROLE doomed_role;
<entry>Allow executing programs on the database server as the user the database runs as with
COPY and other functions which allow executing a server-side program.</entry>
</row>
+ <row>+ <entry>pg_checkpointer</entry>+ <entry>Allow executing the <command>CHECKPOINT</command> command.</entry>+ </row>
</tbody>
</tgroup>
</table>
diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.cindex bf085aa93b2..0ff832a62c2 100644--- a/src/backend/tcop/utility.c+++ b/src/backend/tcop/utility.c@@ -24,6 +24,7 @@
#include "catalog/catalog.h"
#include "catalog/index.h"
#include "catalog/namespace.h"
+#include "catalog/pg_authid.h"
#include "catalog/pg_inherits.h"
#include "catalog/toasting.h"
#include "commands/alter.h"
@@ -939,10 +940,10 @@ standard_ProcessUtility(PlannedStmt *pstmt,
break;
case T_CheckPointStmt:
- if (!superuser())+ if (!has_privs_of_role(GetUserId(), ROLE_PG_CHECKPOINTER))
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
- errmsg("must be superuser to do CHECKPOINT")));+ errmsg("must be member of pg_checkpointer to do CHECKPOINT")));
RequestCheckpoint(CHECKPOINT_IMMEDIATE | CHECKPOINT_WAIT |
(RecoveryInProgress() ? 0 : CHECKPOINT_FORCE));
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.hindex 9faf017457a..f0707678037 100644--- a/src/include/catalog/catversion.h+++ b/src/include/catalog/catversion.h@@ -53,6 +53,6 @@
*/
/* yyyymmddN */
-#define CATALOG_VERSION_NO 202110272+#define CATALOG_VERSION_NO 202111081
#endif
diff --git a/src/include/catalog/pg_authid.dat b/src/include/catalog/pg_authid.datindex 3da68016b61..9c65174f3c6 100644--- a/src/include/catalog/pg_authid.dat+++ b/src/include/catalog/pg_authid.dat@@ -79,5 +79,10 @@
rolcreaterole => 'f', rolcreatedb => 'f', rolcanlogin => 'f',
rolreplication => 'f', rolbypassrls => 'f', rolconnlimit => '-1',
rolpassword => '_null_', rolvaliduntil => '_null_' },
+{ oid => '4544', oid_symbol => 'ROLE_PG_CHECKPOINTER',+ rolname => 'pg_checkpointer', rolsuper => 'f', rolinherit => 't',+ rolcreaterole => 'f', rolcreatedb => 'f', rolcanlogin => 'f',+ rolreplication => 'f', rolbypassrls => 'f', rolconnlimit => '-1',+ rolpassword => '_null_', rolvaliduntil => '_null_' },
]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: pgsql@j-davis.com, sfrost@snowman.net, andres@anarazel.de, robertmhaas@gmail.com, bossartn@amazon.com, alvherre@alvh.no-ip.org, bharath.rupireddyforpostgres@gmail.com
Subject: Re: Predefined role pg_maintenance for VACUUM, ANALYZE, CHECKPOINT.
In-Reply-To: <c5d7045507b0ccac7d9421f52bf3b59b60e1150b.camel@j-davis.com>
References: <202110310026.zmhkxct6ka6c@alvherre.pgsql> <6498F6FC-714B-4AC2-B0E1-9A5321654277@amazon.com> <20211101165025.GS20998@tamriel.snowman.net> <5e7a618de1b49ba1ceede54ee1b1d073bd57f1f4.camel@j-davis.com> <20211104224204.ee5673h3qlzblh7e@alap3.anarazel.de> <ae70a6ff7700a821849be0da6cd0da69e0e4b05e.camel@j-davis.com> <CA+Tgmob9TxDV3X4+=eG9E+o80MW_qoJjTvvHhRt252OO=X9FbA@mail.gmail.com> <20211107184649.mpncdezkzfq2v4pb@alap3.anarazel.de> <20211108172318.GF20998@tamriel.snowman.net> <20211108173325.6ury6xflvxq7yqbn@alap3.anarazel.de> <20211108174723.GI20998@tamriel.snowman.net> <c5d7045507b0ccac7d9421f52bf3b59b60e1150b.camel@j-davis.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox