agora inbox for [email protected]help / color / mirror / Atom feed
[PATCH] Hooks at XactCommand level 967+ messages / 2 participants [nested] [flat]
* [PATCH] Hooks at XactCommand level @ 2020-12-08 10:15 Gilles Darold <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Gilles Darold @ 2020-12-08 10:15 UTC (permalink / raw) To: pgsql-hackers Hi, Based on a PoC reported in a previous thread [1] I'd like to propose new hooks around transaction commands. The objective of this patch is to allow PostgreSQL extension to act at start and end (including abort) of a SQL statement in a transaction. The idea for these hooks is born from the no go given to Takayuki Tsunakawa's patch[2] proposing an in core implementation of statement-level rollback transaction and the pg_statement_rollback extension[3] that we have developed at LzLabs. The extension pg_statement_rollback has two limitation, the first one is that the client still have to call the ROLLBACK TO SAVEPOINT when an error is encountered and the second is that it generates a crash when PostgreSQL is compiled with assert that can not be fixed at the extension level. Although that I have not though about other uses for these hooks, they will allow a full server side statement-level rollback feature like in commercial DBMSs like DB2 and Oracle. This feature is very often requested by users that want to migrate to PostgreSQL. SPECIFICATION ================================================== There is no additional syntax or GUC, the patch just adds three new hooks: * start_xact_command_hook called at end of the start_xact_command() function. * finish_xact_command called in finish_xact_command() just before CommitTransactionCommand(). * abort_current_transaction_hook called after an error is encountered at end of AbortCurrentTransaction(). These hooks allow an external plugins to execute code related to the SQL statements executed in a transaction. DESIGN ================================================== Nothing more to add here. CONSIDERATIONS AND REQUESTS ================================================== An extension using these hooks that implements the server side rollback at statement level feature is attached to demonstrate the interest of these hooks. If we want to support this feature the extension could be added under the contrib/ directory. Here is an example of use of these hooks through the pg_statement_rollbackv2 extension: LOAD 'pg_statement_rollbackv2.so'; LOAD SET pg_statement_rollback.enabled TO on; SET CREATE SCHEMA testrsl; CREATE SCHEMA SET search_path TO testrsl,public; SET BEGIN; BEGIN CREATE TABLE tbl_rsl(id integer, val varchar(256)); CREATE TABLE INSERT INTO tbl_rsl VALUES (1, 'one'); INSERT 0 1 WITH write AS (INSERT INTO tbl_rsl VALUES (2, 'two') RETURNING id, val) SELECT * FROM write; id | val ----+----- 2 | two (1 row) UPDATE tbl_rsl SET id = 'two', val = 2 WHERE id = 1; -- >>>>> will fail psql:simple.sql:14: ERROR: invalid input syntax for type integer: "two" LINE 1: UPDATE tbl_rsl SET id = 'two', val = 2 WHERE id = 1; ^ SELECT * FROM tbl_rsl; -- Should show records id 1 + 2 id | val ----+----- 1 | one 2 | two (2 rows) COMMIT; COMMIT As you can see the failing UPDATE statement has been rolled back and we recover the state of the transaction just before the statement without any client savepoint and rollback to savepoint action. I'll add this patch to Commitfest 2021-01. Best regards [1] https://www.postgresql-archive.org/Issue-with-server-side-statement-level-rollback-td6162387.html [2] https://www.postgresql.org/message-id/flat/0A3221C70F24FB45833433255569204D1F6A9286%40G01JPEXMBYT05 [3] https://github.com/darold/pg_statement_rollbackv2 -- Gilles Darold http://www.darold.net/ Attachments: [text/x-patch] command-start-finish-hook-v2.patch (3.8K, ../../[email protected]/2-command-start-finish-hook-v2.patch) download | inline diff: diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index 9cd0b7c11b..5449446884 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -314,6 +314,9 @@ typedef struct SubXactCallbackItem static SubXactCallbackItem *SubXact_callbacks = NULL; +/* Hook for plugins to get control of at end of AbortCurrentTransaction */ +AbortCurrentTransaction_hook_type abort_current_transaction_hook = NULL; + /* local function prototypes */ static void AssignTransactionId(TransactionState s); static void AbortTransaction(void); @@ -3358,6 +3361,9 @@ AbortCurrentTransaction(void) AbortCurrentTransaction(); break; } + + if (abort_current_transaction_hook) + (*abort_current_transaction_hook) (); } /* diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index 3679799e50..3ed8cb3f94 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -192,6 +192,12 @@ static void log_disconnections(int code, Datum arg); static void enable_statement_timeout(void); static void disable_statement_timeout(void); +/* + * Hooks for plugins to get control at end/start of + * start_xact_command()/finish_xact_command(). + */ +XactCommandStart_hook_type start_xact_command_hook = NULL; +XactCommandFinish_hook_type finish_xact_command_hook = NULL; /* ---------------------------------------------------------------- * routines to obtain user input @@ -2649,8 +2655,16 @@ start_xact_command(void) * not desired, the timeout has to be disabled explicitly. */ enable_statement_timeout(); + + /* + * Now give loadable modules a chance to execute code before a transaction + * command is processed. + */ + if (start_xact_command_hook) + (*start_xact_command_hook) (); } + static void finish_xact_command(void) { @@ -2659,6 +2673,13 @@ finish_xact_command(void) if (xact_started) { + /* + * Now give loadable modules a chance to execute code just before a + * transaction command is committed. + */ + if (finish_xact_command_hook) + (*finish_xact_command_hook) (); + CommitTransactionCommand(); #ifdef MEMORY_CONTEXT_CHECKING diff --git a/src/include/access/xact.h b/src/include/access/xact.h index 7320de345c..2e866b2a91 100644 --- a/src/include/access/xact.h +++ b/src/include/access/xact.h @@ -467,4 +467,8 @@ extern void EnterParallelMode(void); extern void ExitParallelMode(void); extern bool IsInParallelMode(void); +/* Hook for plugins to get control in start_xact_command() and finish_xact_command() */ +typedef void (*AbortCurrentTransaction_hook_type) (void); +extern PGDLLIMPORT AbortCurrentTransaction_hook_type abort_current_transaction_hook; + #endif /* XACT_H */ diff --git a/src/include/tcop/pquery.h b/src/include/tcop/pquery.h index 437642cc72..a8bef2f639 100644 --- a/src/include/tcop/pquery.h +++ b/src/include/tcop/pquery.h @@ -42,4 +42,10 @@ extern uint64 PortalRunFetch(Portal portal, long count, DestReceiver *dest); +/* Hook for plugins to get control in start_xact_command() and finish_xact_command() */ +typedef void (*XactCommandStart_hook_type) (void); +extern PGDLLIMPORT XactCommandStart_hook_type start_xact_command_hook; +typedef void (*XactCommandFinish_hook_type) (void); +extern PGDLLIMPORT XactCommandFinish_hook_type finish_xact_command_hook; + #endif /* PQUERY_H */ diff --git a/src/tools/pgindent/typedefs.list b/src/tools/pgindent/typedefs.list index 04464c2e76..ec28a4c914 100644 --- a/src/tools/pgindent/typedefs.list +++ b/src/tools/pgindent/typedefs.list @@ -13,6 +13,7 @@ A_Expr_Kind A_Indices A_Indirection A_Star +AbortCurrentTransaction_hook_type AbsoluteTime AccessMethodInfo AccessPriv @@ -2793,6 +2794,8 @@ XPVIV XPVMG XactCallback XactCallbackItem +XactCommandStart_hook_type +XactCommandFinish_hook_type XactEvent XactLockTableWaitInfo XidBoundsViolation [application/gzip] pg_statement_rollbackv2.tar.gz (37.7K, ../../[email protected]/3-pg_statement_rollbackv2.tar.gz) download | 1 patch file(s) in archive: pg_statement_rollbackv2/command-start-finish-hook-v1.patch diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index 03c553e7ea..81e1df27ef 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -314,6 +314,9 @@ typedef struct SubXactCallbackItem static SubXactCallbackItem *SubXact_callbacks = NULL; +/* Hook for plugins to get control of at end of AbortCurrentTransaction */ +AbortCurrentTransaction_hook_type abort_current_transaction_hook = NULL; + /* local function prototypes */ static void AssignTransactionId(TransactionState s); static void AbortTransaction(void); @@ -3358,6 +3361,9 @@ AbortCurrentTransaction(void) AbortCurrentTransaction(); break; } + + if (abort_current_transaction_hook) + (*abort_current_transaction_hook) (); } /* diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index 7c5f7c775b..3fff54ff51 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -192,6 +192,14 @@ static void log_disconnections(int code, Datum arg); static void enable_statement_timeout(void); static void disable_statement_timeout(void); +/* + * Hook for plugins to get control at end/start of + * start_xact_command/finish_xact_command. The hook + * on start_xact_command might be useless as it happens + * before UtilityProccess and the Executor* hooks. + */ +XactCommandStart_hook_type start_xact_command_hook = NULL; +XactCommandFinish_hook_type finish_xact_command_hook = NULL; /* ---------------------------------------------------------------- * routines to obtain user input @@ -2634,6 +2642,7 @@ exec_describe_portal_message(const char *portal_name) static void start_xact_command(void) { + if (!xact_started) { StartTransactionCommand(); @@ -2649,11 +2658,19 @@ start_xact_command(void) * not desired, the timeout has to be disabled explicitly. */ enable_statement_timeout(); + + if (start_xact_command_hook) + (*start_xact_command_hook) (); + } + static void finish_xact_command(void) { + if (finish_xact_command_hook) + (*finish_xact_command_hook) (); + /* cancel active statement timeout after each command */ disable_statement_timeout(); diff --git a/src/include/access/xact.h b/src/include/access/xact.h index 7320de345c..2e866b2a91 100644 --- a/src/include/access/xact.h +++ b/src/include/access/xact.h @@ -467,4 +467,8 @@ extern void EnterParallelMode(void); extern void ExitParallelMode(void); extern bool IsInParallelMode(void); +/* Hook for plugins to get control in start_xact_command() and finish_xact_command() */ +typedef void (*AbortCurrentTransaction_hook_type) (void); +extern PGDLLIMPORT AbortCurrentTransaction_hook_type abort_current_transaction_hook; + #endif /* XACT_H */ diff --git a/src/include/tcop/pquery.h b/src/include/tcop/pquery.h index 437642cc72..a8bef2f639 100644 --- a/src/include/tcop/pquery.h +++ b/src/include/tcop/pquery.h @@ -42,4 +42,10 @@ extern uint64 PortalRunFetch(Portal portal, long count, DestReceiver *dest); +/* Hook for plugins to get control in start_xact_command() and finish_xact_command() */ +typedef void (*XactCommandStart_hook_type) (void); +extern PGDLLIMPORT XactCommandStart_hook_type start_xact_command_hook; +typedef void (*XactCommandFinish_hook_type) (void); +extern PGDLLIMPORT XactCommandFinish_hook_type finish_xact_command_hook; + #endif /* PQUERY_H */ diff --git a/src/tools/pgindent/typedefs.list b/src/tools/pgindent/typedefs.list index fde701bfd4..23ddca9891 100644 --- a/src/tools/pgindent/typedefs.list +++ b/src/tools/pgindent/typedefs.list @@ -13,6 +13,7 @@ A_Expr_Kind A_Indices A_Indirection A_Star +AbortCurrentTransaction_hook_type AbsoluteTime AccessMethodInfo AccessPriv @@ -2794,6 +2795,8 @@ XPVIV XPVMG XactCallback XactCallbackItem +XactCommandStart_hook_type +XactCommandFinish_hook_type XactEvent XactLockTableWaitInfo XidBoundsViolation ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
* [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests @ 2026-04-22 09:22 Álvaro Herrera <[email protected]> 0 siblings, 0 replies; 967+ messages in thread From: Álvaro Herrera @ 2026-04-22 09:22 UTC (permalink / raw) These tests sometimes run with wal_level=minimal, which does not allow to run REPACK (CONCURRENTLY). Move them to test_decoding, which is ensured to run with high enough wal_level. Discussion: https://postgr.es/m/[email protected] --- contrib/test_decoding/Makefile | 2 +- contrib/test_decoding/expected/repack.out | 30 +++++++++++++++++++++++ contrib/test_decoding/meson.build | 1 + contrib/test_decoding/sql/repack.sql | 25 +++++++++++++++++++ src/test/regress/expected/cluster.out | 29 +++------------------- src/test/regress/sql/cluster.sql | 13 +++------- 6 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 contrib/test_decoding/expected/repack.out create mode 100644 contrib/test_decoding/sql/repack.sql diff --git a/contrib/test_decoding/Makefile b/contrib/test_decoding/Makefile index acbcaed2feb..0111124399a 100644 --- a/contrib/test_decoding/Makefile +++ b/contrib/test_decoding/Makefile @@ -5,7 +5,7 @@ PGFILEDESC = "test_decoding - example of a logical decoding output plugin" REGRESS = ddl xact rewrite toast permissions decoding_in_xact \ decoding_into_rel binary prepared replorigin time messages \ - spill slot truncate stream stats twophase twophase_stream + repack spill slot truncate stream stats twophase twophase_stream ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \ oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \ twophase_snapshot slot_creation_error catalog_change_snapshot \ diff --git a/contrib/test_decoding/expected/repack.out b/contrib/test_decoding/expected/repack.out new file mode 100644 index 00000000000..70039d824af --- /dev/null +++ b/contrib/test_decoding/expected/repack.out @@ -0,0 +1,30 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; + relname | ?column? +-----------+---------- + ptnowner | t + ptnowner1 | t + ptnowner2 | t +(3 rows) + +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/contrib/test_decoding/meson.build b/contrib/test_decoding/meson.build index cf5b74cf1ab..ac655853d26 100644 --- a/contrib/test_decoding/meson.build +++ b/contrib/test_decoding/meson.build @@ -34,6 +34,7 @@ tests += { 'replorigin', 'time', 'messages', + 'repack', 'spill', 'slot', 'truncate', diff --git a/contrib/test_decoding/sql/repack.sql b/contrib/test_decoding/sql/repack.sql new file mode 100644 index 00000000000..bf66bb441ac --- /dev/null +++ b/contrib/test_decoding/sql/repack.sql @@ -0,0 +1,25 @@ +-- Test REPACK (CONCURRENTLY). +-- This isn't strictly about decoding, but it involves logical decoding +-- and requires to be run under higher than minimal wal_level, so we can't +-- have it in the main regression test suite. + + +-- Ownership of partitions is checked +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; +CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); +ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; +SET SESSION AUTHORIZATION regress_ptnowner; +ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; +REPACK (CONCURRENTLY) ptnowner1; +RESET SESSION AUTHORIZATION; +ALTER TABLE ptnowner OWNER TO regress_ptnowner; +CREATE TEMP TABLE ptnowner_oldnodes AS + SELECT oid, relname, relfilenode FROM pg_partition_tree('ptnowner') AS tree + JOIN pg_class AS c ON c.oid=tree.relid; +SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a + JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; +DROP TABLE ptnowner; +DROP ROLE regress_ptnowner; diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index 71270134985..b767316cf6b 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -552,8 +552,6 @@ ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; ERROR: permission denied for table ptnowner -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -562,30 +560,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; WARNING: permission denied to execute CLUSTER on "ptnowner2", skipping it --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; -ERROR: cannot process relation "ptnowner1" -HINT: Relation "ptnowner1" has no identity index. RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; - relname | ?column? ------------+---------- - ptnowner | t - ptnowner1 | f - ptnowner2 | t -(3 rows) - DROP TABLE ptnowner; DROP ROLE regress_ptnowner; -- Test CLUSTER with external tuplesorting @@ -731,6 +706,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- checking if it handles table hierarchies identically as well. diff --git a/src/test/regress/sql/cluster.sql b/src/test/regress/sql/cluster.sql index 6746236ffec..a22c75282ee 100644 --- a/src/test/regress/sql/cluster.sql +++ b/src/test/regress/sql/cluster.sql @@ -262,8 +262,6 @@ CREATE TABLE ptnowner2 PARTITION OF ptnowner FOR VALUES IN (2); ALTER TABLE ptnowner1 OWNER TO regress_ptnowner; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; -ALTER TABLE ptnowner1 REPLICA IDENTITY USING INDEX ptnowner1_i_key; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; ALTER TABLE ptnowner OWNER TO regress_ptnowner; CREATE TEMP TABLE ptnowner_oldnodes AS @@ -271,14 +269,7 @@ CREATE TEMP TABLE ptnowner_oldnodes AS JOIN pg_class AS c ON c.oid=tree.relid; SET SESSION AUTHORIZATION regress_ptnowner; CLUSTER ptnowner USING ptnowner_i_idx; --- still can't repack without a replica identity -ALTER TABLE ptnowner1 REPLICA IDENTITY DEFAULT; -REPACK (CONCURRENTLY) ptnowner1; RESET SESSION AUTHORIZATION; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; -SELECT a.relname, a.relfilenode=b.relfilenode FROM pg_class a - JOIN ptnowner_oldnodes b USING (oid) ORDER BY a.relname COLLATE "C"; DROP TABLE ptnowner; DROP ROLE regress_ptnowner; @@ -346,6 +337,10 @@ COMMIT; -- -- REPACK -- +-- Note we cannot test working REPACK (CONCURRENTLY) here, because the +-- tests could be run with wal_level=minimal, so those tests are +-- elsewhere. +-- ---------------------------------------------------------------------- -- REPACK handles individual tables identically to CLUSTER, but it's worth -- 2.47.3 --5vljmhsecqh6fok5-- ^ permalink raw reply [nested|flat] 967+ messages in thread
end of thread, other threads:[~2026-04-22 09:22 UTC | newest] Thread overview: 967+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2020-12-08 10:15 [PATCH] Hooks at XactCommand level Gilles Darold <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]> 2026-04-22 09:22 [PATCH] Move REPACK (CONCURRENTLY) test out of stock regression tests Álvaro Herrera <[email protected]>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox