pg.ddx.io  reorg/pg_repack GitHub issues and pull requests  
help / color / mirror / Atom feed
From: za-arthur (@za-arthur) <noreply+za-arthur@github.com>
To: reorg/pg_repack <noreply+reorg-pg_repack@github.com>
Subject: [reorg/pg_repack] PR #494: Prevent operator shadowing in the repack.tables view
Date: Sat, 14 Nov 2026 22:55:36 +0000
Message-ID: <gh-reorg-pg_repack-494@github.com> (raw)

CREATE EXTENSION without `schema =` in the control file runs the install script with `search_path = <target schema>, pg_temp`. A role that can create objects in that schema can define operators whose argument types match better than the built-in ones, and the view binds to them when it is created.

Cast the integer constants to `pg_catalog.oid`, and use `OPERATOR(pg_catalog.!~~)` for the LIKE comparison so the lookup is limited to `pg_catalog`.

Follow up of https://github.com/reorg/pg_repack/pull/493

I accidentally pushed the commit 5c3233bb50823b630feba36e64f4e463c3ef04f8 into `master` 😞 , I reverted it and created the PR instead.

inline patch 1: lib/pg_repack.sql.in (+3/-3 lines) download inline-1.patchdiff --git a/lib/pg_repack.sql.in b/lib/pg_repack.sql.in index 9bc94fc..f07b844 100644 --- a/lib/pg_repack.sql.in +++ b/lib/pg_repack.sql.in @@ -312,7 +312,7 @@ CREATE VIEW repack.tables AS SELECT repack.oid2text(R.oid) AS relname, R.oid AS relid, R.reltoastrelid AS reltoastrelid, - CASE WHEN R.reltoastrelid = 0 THEN 0 ELSE ( + CASE WHEN R.reltoastrelid = 0::pg_catalog.oid THEN 0 ELSE ( SELECT indexrelid FROM pg_catalog.pg_index WHERE indrelid = R.reltoastrelid AND indisvalid) END AS reltoastidxid, @@ -354,7 +354,7 @@ CREATE VIEW repack.tables AS WHERE CKI.indisvalid AND CKI.indexrelid = CKT.oid AND CKI.indisclustered - AND CKT.relam = 403) CK + AND CKT.relam = 403::pg_catalog.oid) CK ON R.oid = CK.indrelid LEFT JOIN pg_catalog.pg_namespace N ON N.oid = R.relnamespace LEFT JOIN pg_catalog.pg_tablespace S ON S.oid = R.reltablespace @@ -365,7 +365,7 @@ CREATE VIEW repack.tables AS WHERE R.relkind = 'r' AND R.relpersistence = 'p' AND N.nspname NOT IN ('pg_catalog', 'information_schema') - AND N.nspname NOT LIKE E'pg\\_temp\\_%'; + AND N.nspname OPERATOR(pg_catalog.!~~) E'pg\\_temp\\_%'; CREATE FUNCTION repack.repack_indexdef(oid, oid, name, bool) RETURNS text AS 'MODULE_PATHNAME', 'repack_indexdef'

view thread (7+ messages)  latest in thread

Message-ID: <gh-reorg-pg_repack-494@github.com>
Permalink:  ../gh-reorg-pg_repack-494@github.com/

 ·  · 


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