mirror of
https://git.postgresql.org/git/postgresql.git
synced 2026-02-14 02:17:02 +08:00
Commit aac2c9b4fde889d13f859c233c2523345e72d32b mandated such locking and attempted to fulfill that mandate, but it missed REASSIGN OWNED. Hence, it remained possible to lose VACUUM's inplace update of datfrozenxid if a REASSIGN OWNED processed that database at the same time. This didn't affect the other inplace-updated catalog, pg_class. For pg_class, REASSIGN OWNED calls ATExecChangeOwner() instead of the generic AlterObjectOwner_internal(), and ATExecChangeOwner() fulfills the locking mandate. Like in GRANT, implement this by following the locking protocol for any catalog subject to the generic AlterObjectOwner_internal(). It would suffice to do this for IsInplaceUpdateOid() catalogs only. Back-patch to v13 (all supported versions). Kirill Reshke. Reported by Alexander Kukushkin. Discussion: https://postgr.es/m/CAFh8B=mpKjAy4Cuun-HP-f_vRzh2HSvYFG3rhVfYbfEBUhBAGg@mail.gmail.com
25 lines
924 B
PL/PgSQL
25 lines
924 B
PL/PgSQL
CREATE DATABASE regression_tbd
|
|
ENCODING utf8 LC_COLLATE "C" LC_CTYPE "C" TEMPLATE template0;
|
|
ALTER DATABASE regression_tbd RENAME TO regression_utf8;
|
|
ALTER DATABASE regression_utf8 SET TABLESPACE regress_tblspace;
|
|
ALTER DATABASE regression_utf8 RESET TABLESPACE;
|
|
ALTER DATABASE regression_utf8 CONNECTION_LIMIT 123;
|
|
|
|
-- Test PgDatabaseToastTable. Doing this with GRANT would be slow.
|
|
BEGIN;
|
|
UPDATE pg_database
|
|
SET datacl = array_fill(makeaclitem(10, 10, 'USAGE', false), ARRAY[5e5::int])
|
|
WHERE datname = 'regression_utf8';
|
|
-- load catcache entry, if nothing else does
|
|
ALTER DATABASE regression_utf8 RESET TABLESPACE;
|
|
ROLLBACK;
|
|
|
|
CREATE ROLE regress_datdba_before;
|
|
CREATE ROLE regress_datdba_after;
|
|
ALTER DATABASE regression_utf8 OWNER TO regress_datdba_before;
|
|
REASSIGN OWNED BY regress_datdba_before TO regress_datdba_after;
|
|
|
|
DROP DATABASE regression_utf8;
|
|
DROP ROLE regress_datdba_before;
|
|
DROP ROLE regress_datdba_after;
|