Subject: [PATCH 2/2] REPACK: do not require LOGIN privileges

From: Álvaro Herrera <[email-masked]>
Date: Mon, 20 Apr 2026 13:19:49 +0200

Normally, starting a background worker does require LOGIN, which is
fine.  However, the bgworker used for REPACK has no business requiring
it.  It's just user-unfriendly and prevents repacking tables
comfortably.
---
 src/backend/commands/repack_worker.c  | 5 +++--
 src/test/regress/expected/cluster.out | 2 +-
 src/test/regress/sql/cluster.sql      | 2 +-
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/backend/commands/repack_worker.c b/src/backend/commands/repack_worker.c
index e4a4860805b..c40f8c98e06 100644
--- a/src/backend/commands/repack_worker.c
+++ b/src/backend/commands/repack_worker.c
@@ -106,8 +106,9 @@ RepackWorkerMain(Datum main_arg)
 	pq_set_parallel_leader(shared->backend_pid,
 						   shared->backend_proc_number);
 
-	/* Connect to the database. */
-	BackgroundWorkerInitializeConnectionByOid(shared->dbid, shared->roleid, 0);
+	/* Connect to the database. LOGIN is not required. */
+	BackgroundWorkerInitializeConnectionByOid(shared->dbid, shared->roleid,
+											  BGWORKER_BYPASS_ROLELOGINCHECK);
 
 	/*
 	 * Transaction is needed to open relation, and it also provides us with a
diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out
index e17bc91fae1..71270134985 100644
--- a/src/test/regress/expected/cluster.out
+++ b/src/test/regress/expected/cluster.out
@@ -546,7 +546,7 @@ DROP TABLE clstrpart;
 CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i);
 CREATE INDEX ptnowner_i_idx ON ptnowner(i);
 CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1);
-CREATE ROLE regress_ptnowner LOGIN;
+CREATE ROLE regress_ptnowner;
 CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2);
 ALTER TABLE ptnowner1 OWNER TO regress_ptnowner;
 SET SESSION AUTHORIZATION regress_ptnowner;
diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql
index 1f471a8821a..6746236ffec 100644
--- a/src/test/regress/sql/cluster.sql
+++ b/src/test/regress/sql/cluster.sql
@@ -257,7 +257,7 @@ DROP TABLE clstrpart;
 CREATE TABLE ptnowner(i int unique not null) PARTITION BY LIST (i);
 CREATE INDEX ptnowner_i_idx ON ptnowner(i);
 CREATE TABLE ptnowner1 PARTITION OF ptnowner FOR VALUES IN (1);
-CREATE ROLE regress_ptnowner LOGIN;
+CREATE ROLE regress_ptnowner;
 CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2);
 ALTER TABLE ptnowner1 OWNER TO regress_ptnowner;
 SET SESSION AUTHORIZATION regress_ptnowner;
-- 
2.47.3

--m6zy3l65ushq557m--