pgsql: Fix REPACK (CONCURRENTLY) when the table owner lacks CONNECT.

From: Masahiko Sawada <msawada(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix REPACK (CONCURRENTLY) when the table owner lacks CONNECT.
Date: 2026-09-08 19:06:47
Message-ID: E1x419a-00000004202-0S6E@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix REPACK (CONCURRENTLY) when the table owner lacks CONNECT.

REPACK (CONCURRENTLY) launches a background worker to decode changes
made while the table is being rewritten. The worker connects as the
table owner but bypassed the LOGIN check only, so CONNECT was still
checked against a role that need not have it, and the command could
fail with "permission denied for database".

Pass BGWORKER_BYPASS_ALLOWCONN as well, as we do for parallel
workers. That is safe because the leader already checked the invoking
user's privileges on the table before starting the worker.

Reported-by: Nathan Bossart <nathandbossart(at)gmail(dot)com>
Author: Matheus Alcantara <mths(dot)dev(at)pm(dot)me>
Reviewed-by: Nathan Bossart <nathandbossart(at)gmail(dot)com>
Reviewed-by: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
Reviewed-by: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Reviewed-by: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
Discussion: https://postgr.es/m/apBbzFd_EYAfHV45@nathan
Backpatch-through: 19

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/9bf3a414560d93ef8e8cf61748cd5783ab4bc9f9

Modified Files
--------------
src/backend/commands/repack_worker.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Masahiko Sawada 2026-09-08 20:06:18 pgsql: Restrict REPACK (CONCURRENTLY) on user catalog tables.
Previous Message Masahiko Sawada 2026-09-08 19:06:43 pgsql: Fix REPACK (CONCURRENTLY) when the table owner lacks CONNECT.